1.3. Provisioning an iPhone

If you want to install your applications on the iPhone, you'll need a developer certificate and a mobile provisioning profile from Apple. You can create these through the iPhone Developer Program portal. You'll need to pay a fee to join one of the program tracks before you can create a profile. You may sign up by registering at http://developer.apple.com. Once you've been accepted into the developer program, you'll be provided instructions to access the developer's portal.

To get set up, you'll perform the following basic steps. Because the program portal's interface is subject to change, use the following only as a guide and be sure to follow the portal's online instructions:

  • Log into the program portal. The first thing to do is create a developer certificate. Xcode uses this certificate to sign your applications. Click the Certificates tab and follow the instructions to add a new certificate. Once created, download the certificate and the WWDR Intermediate Certificate as instructed. The WWDR Intermediate Certificate is Apple's key, which you'll also need. Once downloaded, double-click each of these certificates to add them to your keychain.

  • Now register your iPhone in the portal by clicking the Devices tab. Registering your iPhone is necessary because you can only install your test applications on registered devices. You'll need your iPhone's unique device ID, which you can obtain from Xcode's device organizer. Launch Xcode, then go to the Windows menu and select Organizer. This will cause a window, shown in Figure 1-2, to appear with a list of devices. Connect your iPhone, and you will be prompted to use the device for development. Click the device in the left pane of the organizer. An information window will appear containing the device ID of the iPhone. Use this to register your iPhone in the program portal.

  • Next, click the App IDs tab to create an application bundle identifier. This identifies the application (or group of applications) you'll be developing. This identifier can be wildcarded, allowing you to install any application using a given bundle prefix. To run this book's examples on your iPhone, create a wildcard using com.yourcompany.* as a bundle identifier. You can name the application "Examples," or whatever you like.

  • Next, create a provisioning profile for your mobile device. The provisioning profile allows you to install applications compiled with the identifier you've just created on your iPhone. Select the application ID to associate with the profile, as well as the developer certificates and devices to use with the profile. After you've created the profile, download it to your desktop.

  • To add the provisioning profile to your iPhone, click the plus sign (+) in the organizer underneath the box labeled Provisioning and navigate to your provisioning certificate. Once installed, you'll be able to install applications onto this device from Xcode.



The organizer window also allows you to view the console and crash logs from your device, and take screenshots.

Figure 1-2. Xcode Organizer window