IPhone program debugging on a real machine

Source: Internet
Author: User

Debugging iPhone applications on a real machine

1. Overview of real machine debugging process

1) To debug applications on a real machine, you must first have an apple developer account to create a certificate request CSR;

2) Open the application key string access (keychain access) to request the certificate;

3) log on to the IDP Portal "Certificates" to submit a certificate request;

4) after you confirm the submission, refresh the page to automatically generate the. Cer file and download it to your local device;

5) double-click the. Cer file to place the certificate to the key string for access;

6) obtain the device's udid through iTunes or xcode (organizer;

7) Go Back To The IDP Portal "devices" column to register the device, and fill in the device udid and user name information;

8) after completing device registration, go to the IDP Portal "app IDs" topic, apply for an app ID, and fill in the description of the app ID and related information bound to the application;

9) after completing the application for app ID, go to the "provisioning" topic of the IDP portal and fill in the provisioning file name, Certificate Name, device to be registered, and app ID, these options are all completed in the previous steps;

10) If you have completed application development and debugging, you can go to the IDP Portal "distribution" topic of the release program and start releasing the application. However, the request for publishing the certificate created by the application is different from the real machine test, but the basic process is the same;

The general process for debugging applications on a real machine is shown in:

Figure 1-1

 

2. Detailed debugging process of a real machine 2.1. Request a certificate

First, open the keychain access to create a certificate request (in the application utility), as shown in:

Key string access Figure 2-1

Select the "Key Access string", "certificate assistant", and "request certificate from Certificate Authority" option to open the "Certificate assistant" dialog box, as shown in:

Certificate assistant Figure 2-2

Fill in the relevant information and select "Save to disk" and "let me specify key information" as the request and click "continue ". Select a storage path. Finally, generate the certificate request file. certsigningrequest.

2.2. submit a certificate

After generating the request Certificate file, log on to the IDP provisioning portal page, select the certificate column, request the certificate, and click the request certificates button, as shown in:

Request certificate Diagram 2-3

Go to the create development certificate page, select the created ". certsigningrequest", and select "Submit ". As shown in:

Certificate generation Diagram 2-4

After refreshing the page, click the "Download" button to save the certificate (. Cer file) locally.

2.3 Register (install) the certificate

After the download is complete, double-click the. Cer file to install the certificate. After that, it can be displayed in keychain access. If the certificate is successfully installed, the green text-"This certificate is valid" is displayed. If the certificate fails to be created, the red text-"This certificate is invalid" is displayed ". When the certificate is invalid, the cause and solution of the problem will be discussed in section 3.

2.4 obtain the device udid

Open xcode, select window, open the organizer dialog box, and copy the device's udid. You must connect to the device. Otherwise, you cannot obtain the device's udid (which can also be obtained from iTunes, but cannot be copied) as shown in:

Organizer Figure 2-5

2.5 register a device

After obtaining the device's udid, return to the IDP provisioning portal page, select the certificate column, and click "add devices" to register the device, as shown in:

Register a device 2-6

Enter the device information page. The first is the device name (which can be entered according to the developer's intent), and the second is the device's udid, which is to be registered into the device's udid. As shown in:

Register a device 2-7

2.6 register app IDS

After the device is registered, go to the "app IDs" page to register the app ID, and click "new app ID", as shown in:

Figure 2-8 create an app ID

When entering the app ID, the description of the information can be filled by the developer at will, but do not include special characters, such as "@" and; however, filling in the "bundle identifier" is very important. If this information is incorrect, the real machine test application cannot be completed. There are two specific methods. Let's take a look at a Use Case "com. domainname. appname" provided by Apple ". The naming rules must be followed. The first ". "com" must be filled in according to the style provided by Apple, while "domainname" must be customized by users. This part of information can be filled in by developers at will, but apple recommends the company's domain name. The last part indicates the name of the application to be tested. For example, if an application called app is created when the xcode file is created, enter the app. Of course, it can also be replaced by "*", which means it can be used for testing any iPhone program. The second type is recommended in this article. As shown in:

App id 2-9

2.7 generate the provisioning File

After generating the app IDs, select the "provisioning" Page and click "New provisioning file" to create the provisioning file. The first entry is the profile name, which can be entered as required by the developer, next, select the created certificate. CER file, select the app ID, and then select the device you want to register. Click OK to create the profile file. Refresh the page and download the. mobleprovisioning file.

App id 2-9

2.8 install the provisioning File

After downloading the provisioning file, double-click the installation file. Check whether the provisioning file is correctly installed on the device. Open xcode and check it in the organizer dialog box.

2.9 configure the xcode File

Finally, configure the xcode file, open the plist file, and change "yourcompany" in "bundle identifier" to the Company domain name. And must be consistent with the app ID. For example, when creating an app ID. apple. * ", the plist file is also changed to" com. apple. * ***** "and" * "do not need to be modified. As shown in:

Bundle identifier Figure 2-10

Select info of the xcode project and select the "code signing identifier" option as the created mobileprovisioning file. As shown in:

Code signing Figure 2-11

If not, it indicates that some previous operations are incorrect. Please follow this method to recreate the certificate. You can also learn to refer to the real machine test videos provided by Apple.

3. Precautions for debugging on a real machine 3.1. Request a certificate in keychain access

Before creating a request certificate, you must set the keychain access. Open the keychain preference settings option, select the certificate, and select "OCSP" and "CRL" as disabled, and set the priority to "OCSP", but generally do not need to be modified because it is the default item. As shown in:

Keychain preference settings Figure 3-1

3.2 if the certificate is invalid, there are two reasons for "This certificate is invalid" (I have not encountered the latter reason, I guess, haha ). The essence is related to time. The first one is that the time set by the Mac computer may be incorrect. If you change it back to the correct time and create a certificate, there should be no problem, however, an error may occur during a real machine test. Delete the build file and the application folder generated file. The second reason is that the certificate validity period has passed (1 year ). 3.3 If you are prompted about too many certificates, go back to the "keychain access" application and delete unnecessary certificates. The keys of other certificates can be retained. If you delete them, xcode will report an error when you test other devices or applications, prompting you that the keys and certificates do not match. Of course, you can also export and back up the key to avoid accidental deletion. Right-click to export the key to be backed up. 3.3 other real machine testing procedures

If you want to test on another Mac computer, you need to export the private key from keychain access to another Mac computer. Open the keychain application and right-click the private key to export it. When exporting the private key, the Mac will prompt you to enter the key password.

 

Conclusion: There are three important steps to test applications on the iPhone.

1. Request a certificate from keychain access and create a certificate request file, that is, CSR, in order to get a. Cer file, that is, the certificate

2. Create an app ID file. This is the ID number bound to your application. Do not think it is an Apple ID. It should be applicaiton ID, that is, you need to debug the application, in general, this step is prone to errors, that is, your app ID is inconsistent with the buddle in your plist file, leading to the failure of real-machine debugging. We recommend that you end with "X, in this way, the app ID can correspond to any application.

3. Create a provision file. All the steps are for it. Here you will select your app ID, device name, and other related information. It is successfully installed, so that your device can be tested on a real machine, you can view it in xcode organize, or you can see it in the device (Set/General/description file)

Add one more point: Once you can perform a real machine test, if you use another device to test the program, you do not need to perform the preceding steps to directly register the device and modify the created profile file, add another device. Finally, install the provision file. That is to say, this provision file can support multiple devices at the same time. (If the test is still unavailable, you can refer to the official video and documentation for details, but it will be slightly different, because it is the materials from January 1, 2008 and may be subject to some changes now, but it should be the same in general)

Finally, I wish you a successful and well-rounded iPhone program. Please give me some advice. If you have any errors or technical exchanges, please send an email

[Email protected]

 

Bite Apple ing...

IPhone program debugging on a real machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.