iPhone OS Reference Library Apple Developer Connection spyglass button

Managing Devices

With iPhone Simulator you can start developing iPhone applications without using iPhone OS–based devices. This way you can familiarize yourself with the API and development workflows used to develop applications. However, you must always test your applications on actual devices before publishing them to ensure that they run as intended and to tune them for performance on actual hardware.

As a registered iPhone developer you can log in to the iPhone Dev Center, which provides access to iPhone developer documentation and lets you build iPhone applications that run in iPhone Simulator. (To become a registered iPhone developer, visit http://developer.apple.com/iphone.) Being a registered iPhone developer, however, doesn’t allow you to run applications on iPhone OS–based devices. To do so you must be a member of the iPhone Developer Program. See “Accessing the iPhone Developer Program Portal” for more information.

This chapter shows how to add your development devices to the iPhone Developer Program and how to configure your computer for development. It also shows how to use the Xcode Organizer window to view your application’s console logs or crash information, or to take screenshots of your application as it runs. The chapter also describes how to safeguard the digital identifications required to install applications in development in devices.

Accessing the iPhone Developer Program Portal

The iPhone Developer Program provides the tools and resources you need to run applications on development devices and distribute them to iPhone OS users. To become a member of the iPhone Developer Program, visit http://developer.apple.com/iphone/program.

After becoming an iPhone Developer Program member, you have access to the iPhone Developer Program Portal in the iPhone Dev Center. The iPhone Developer Program Portal (or Program Portal) is a restricted-access area of the iPhone Dev Center that allows you to configure devices to test your iPhone applications on them.

Important: If you are not a member of the iPhone Developer Program, you do not have access to the Program Portal.

Preparing Devices for Development

In order to test your application on a device, you must configure your computer and your device for iPhone OS development. This section presents an overview of the process and provides detailed information in the sections that follow.

In preparing your device for development, you create or obtain the following digital assets:

Figure 5-1 illustrates the relationship between these digital assets.

Figure 5-1  Preparing computers and devices for iPhone development

Description: Diagram illustrates the realationship between your computer, a certificate signing request, the iPhone Developer Program Portal, a provisioning profile, your development certificate, Xcode Organizer, your keychain, and your device.

These are the requirements your computer and your development device must meet so that you can build iPhone applications that run on your device:

These are the steps you must follow to configure your computer and development device for iPhone development:

  1. Specify your application ID.

  2. Register your device with the Program Portal.

  3. Install iPhone OS on your device.

  4. Obtain your development certificate.

  5. Add your development certificate to your keychain.

  6. Obtain your provisioning profile.

  7. Add your provisioning profile to Xcode.

  8. Install your provisioning profile on your device.

The following sections describe these tasks in detail.

Setting Your Application ID

After becoming a member of the iPhone Developer Program (see “Accessing the iPhone Developer Program Portal”), you must set your application ID in the Program Portal. iPhone OS uses application IDs to identify the applications you create. An iPhone application ID is made up of a ten-character bundle seed identifier and a bundle identifier. The bundle identifier can identify one application or a group of applications.

This is an example of an iPhone application ID that identifies a single application, named MyApp:

GFWOTNXFIY.com.mycompany.MyApp

Using an asterisk instead of an application name in the bundle identifier, as shown below, lets you share a single application ID between a set of related applications.

GFWOTNXFIY.com.mycompany.myappsuite.*
Note: Regardless of the format used by the iPhone application ID, application bundles must always include the application name in their bundle identifier. To learn more about the bundle identifier, see “The Application Bundle” in iPhone Application Programming Guide.

Registering Your Device with the Program Portal

To register your development device with the portal:

  1. Launch Xcode.

  2. Choose Window > Organizer to open the Organizer window.

  3. Plug-in your device and select it in the devices list.

  4. Copy your device UDID from the Identifier text field in the Summary pane, as shown in Figure 5-2.

    Figure 5-2  Organizer: Copying your device identifier

    Organizer window with device identifier selected.
  5. Go to the portal to register your device or have your team admin register your device into the program. For more information about the portal, “Accessing the iPhone Developer Program Portal.”

Installing iPhone OS on Your Device

To run applications you develop using the iPhone SDK, your device must be running iPhone OS 2.0 or later.

To learn how to install iPhone OS on your device, see “Restoring System Software.”

Obtaining Your Development Certificate

Xcode uses your development certificate to code-sign your application before it uploads it to your device for testing.

Start by generating a certificate signing request (CSR) on your computer:

  1. Launch Keychain Access, located in /Applications/Utilities.

  2. Choose Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.

  3. In the Certificate Information window:

    1. In the User Email Address field, enter your email address.

    2. In the Common Name field, enter your name.

    3. In the “Request is” group, select the “Saved to disk” option.

    4. Select “Let me specify key pair information.”

    5. Click Continue.

    6. Choose your desktop as the location for the CSR file.

    7. In the Key Pair Information pane, choose 2048 as the key size and RSA as the algorithm.

    The Certificate Assistant saves a CSR file to your desktop.

    This process creates a public/private key pair. The public key is stored in your development certificate. Your private key is stored in your keychain. You must ensure that you don’t lose your private key and that only you have access to it. Therefore, it’s a good idea to backup your private key. Backing up your private key may also help if you need to use more than one computer to develop iPhone applications. You should also save your CSR, for future use. See “Managing Your Digital Identities” for more information.

  4. Submit the CSR to the Program Portal.

After the CSR is approved by your team admin, you can download your development certificate from the Program Portal (see “Accessing the iPhone Developer Program Portal”). As with your private key, you should backup your development certificate in case you need to develop iPhone applications on another computer. See “Managing Your Digital Identities” for details.

Adding Your Development Certificate to Your Keychain

Your development certificate must be in your keychain so that Xcode can digitally sign your iPhone applications.

To add your development certificate to your keychain, in your computer:

  1. Open your development certificate with the Keychain Access application by double-clicking it or dragging it to the Keychain Access application icon.

  2. In the Add Certificates dialog, ensure Keychain is set to “login” and click OK.

Obtaining Your Provisioning Profile

To obtain your provisioning profile:

  1. Have your team admin create your provisioning profile in the Program Portal.

  2. Download your provisioning profile from the Program Portal (see “Accessing the iPhone Developer Program Portal”).

Adding Your Provisioning Profile to the Xcode Organizer

You use the Organizer to add provisioning profiles to your development device.

To add a provisioning profile to Xcode, drag the provisioning profile file to the Xcode icon in the Dock. After this action your provisioning profile appears in the Provisioning Profiles list in the Organizer.

Installing Your Provisioning Profile on Your Device

After adding your provisioning profile to the Organizer, you can add it to your device:

  1. Open the Organizer window.

    Your provisioning profile should appear in the Provisioning Profiles list. If you don’t see it there, follow the instructions in “Adding Your Provisioning Profile to the Xcode Organizer.”

  2. Plug in your device.

  3. Drag your provisioning profile from the Provisioning Profiles list to your device, under the Devices group in the Organizer sidebar.

    Once installed, a checkmark should appear in the checkbox next to the provisioning profile. If the checkmark doesn’t appear, ensure that the provisioning profile includes your device UDID, your development certificate, and a valid application ID. Go to the Program Portal (see “Accessing the iPhone Developer Program Portal”) or contact your team admin to verify that the provisioning profile contains this information . You need to go back to the “Obtaining Your Provisioning Profile” step if changes are made to your profile.

    Troubleshooting: If your provisioning profile does not appear in the Provisioning section of the Summary pane in the Organizer while your device is selected in the Devices list, quit and relaunch Xcode.

Restoring System Software

When you develop applications using the iPhone SDK, you should test those applications on devices running the iPhone OS version the SDK targets. You can download the latest release of the iPhone SDK from the iPhone Dev Center. Use iTunes to install the latest iPhone OS onto your device.

Note: During seed periods, you can download seed releases of the iPhone SDK and iPhone OS from the iPhone Dev Center.

To restore a device:

  1. Launch Xcode and open the Organizer window.

  2. Plug the device into your computer.

  3. Select the device in the Devices list.

  4. From the Software Version pop-up menu, choose the version of iPhone OS you want to place on the device.

    If you’re using a seed release of the iPhone SDK and the version of iPhone OS you want to install is not listed in the Software Version pop-up menu:

    1. Download the iPhone OS seed that corresponds to your iPhone SDK seed from http://developer.apple.com.

      Important: You must be a member of the iPhone Developer Program to be able to download iPhone OS.

    2. From the Software Version pop-up menu, choose Other Version.

    3. Navigate to the disk image containing the iPhone OS developer software and click Open.

      Xcode extracts the iPhone OS software from the disk image. You can dispose of the disk image you downloaded.

    4. From the Software Version pop-up menu, choose the newly downloaded iPhone OS version.

    During nonseed periods, you must install iPhone OS using iTunes.

  5. Click Restore iPhone or Restore iPod, depending on your device’s type.

  6. Use iTunes to name your device.

Running Applications on a Device

After following the instructions in “Preparing Devices for Development” and “Restoring System Software” (if necessary) you can run your application on your development device.

You tell Xcode that you want to build your application for a device and that you want to run it on a connected device by setting the active SDK to an iPhone Device SDK. See “Building Your Application” for details.

Capturing Screen Shots

Screen shots help to document your application. This is also how you create your application’s default image, which iPhone OS displays when the user taps your application’s icon. You can capture screen shots of your device’s screen from the Organizer or directly on your device.

To capture a screen shot from the Organizer:

  1. Configure your application’s screen for the screen shot.

    Depending on your application’s workflow, you may need to place breakpoint in your code and run your application until it reaches that point.

  2. Open the Organizer window, select your device, and click Screenshots.

  3. Click Capture.

    To make that screen shot your application’s default image, click Save As Default Image.

    To get a PNG file of the screenshot, drag it to the desktop.

If you have iPhoto installed on your computer, you may capture screen shots directly on your device and import them into your iPhoto library.

To capture a screen shot on your device, press the the Lock and Home buttons simultaneously. Your screen shot is saved in the Saved Photos album in the Photos application.

Note: Although the default image includes the status bar as it looked when the screen shot was captured, iPhone OS replaces it with the current status bar when your application launches.

Managing Your Digital Identities

When you create a certificate signing request (CSR) to obtain your development certificate, you generate a public/private key pair. The public key is included in your development certificate. The private key is stored in your keychain. With these two items in your computer, Xcode can code-sign the iPhone applications you build with it. If you need to use another computer to develop iPhone applications, you must transfer these items to the other computer and add them to your keychain.

This section shows how to export your private key from your keychain in your development computer, store your CSR, private key, and development certificate in a protected disk image, and add these items to a second computer for iPhone development.

To export your private key from your keychain:

  1. Launch Keychain Access.

  2. In the category list, select Keys.

  3. Select the private key you use for iPhone development.

  4. Choose Export from the private key shortcut menu.

    (To display the private key shortcut menu, Control-click the selected row.)

  5. Enter a password to protect the private key.

  6. Select a location for the private key and use the Personal Information Exchange (.p12) format for the file.

To generate a protected disk image containing your CSR, private key, and development certificate:

  1. Place your CSR, private key, and development certificate file in a newly created directory, named iPhone Developer Identity Documents.

  2. Launch the Disk Utility application, located in /Applications/Utilities.

  3. Choose File > New > Disk Image from Folder.

  4. Choose the iPhone Developer Identity Documents directory you created earlier.

  5. Select a location for the new protected disk image.

  6. From the Encryption pop-up menu, choose “256-AES encryption”.

  7. In the dialog that appears, enter a password for the disk image.

    You should deselect the “Remember password in my keychain” option. Otherwise, anybody with access to your account may open the disk image.

  8. Place the protected disk image in a secure location.

Now, when you need to develop iPhone applications on another computer:

  1. Copy the iPhone Developer Identity Documents.dmg disk-image file to the second computer.

  2. On the second computer, open the disk image.

  3. Import the private key into your keychain:

    1. Launch Keychain Access.

    2. Choose File > Import Items.

    3. Choose the private key file to import.

  4. Add the development certificate to your keychain. See “Adding Your Development Certificate to Your Keychain” for details.



Last updated: 2009-08-06

Did this document help you? Yes It's good, but... Not helpful...