MOBILE

Creating a Development Provisioning Profile on iPhone

9/14/2010 9:29:16 AM

Even after you’ve obtained an Apple Developer Membership, joined a paid Developer Program, and downloaded and installed the iOS development tools, you still won’t be able to run on your iPhone any applications that you write! Why? Because you haven’t created a development provisioning profile yet.

In many development guides, this step isn’t covered until after development begins. In my mind, once you’ve written an application, you’re going to want to immediately run it on the iPhone. Why? Because it’s just cool to see your own code running on your own device!

What’s a Development Provisioning Profile?

Like it or not, Apple’s current approach to iOS development is to make absolutely certain that the development process is controlled—and that groups can’t just distribute software to anyone they want. The result is a rather confusing process that ties together information about you, any development team members, and your application into a “provisioning profile.”

A development provisioning profile identifies the developer who may install an application, an ID for the application being developed, and the “unique device identifiers” for each iPhone that will run the application. This is only for the development process. When you are ready to distribute an application via the App Store or to a group of testers (or friends!) via ad hoc means, you’ll need to create a separate “distribution” profile. Because we’re just starting out, this isn’t something you’ need right away.

Generating and Installing a Development Provisioning Profile

Creating a provisioning profile can be frustrating and seem outrageously convoluted. Apple has streamlined the process tremendously with an online Development Provisioning Assistant, but we still have to jump through some hoops. Let’s bite the bullet and get through this!

Getting Your iPhone Unique Device Identifier

To run your application on a real iPhone, you need the ID that uniquely identifies your iPhone from the thousands of other iPhones. To find this, first make sure that your device is connected to your computer, and then launch Xcode from the Developer/Applications folder. When Xcode first launches, immediately choose Window, Organizer from the menu. The Organizer utility slightly resembles iTunes in its layout. You should see your iPhone listed in the far-left column of the Organizer under the Devices section. Click the icon to select it, and then click the “Use for Development” button. Your screen should now resemble Figure 1

Figure 1. First, grab the ID of your iPhone.


The Identifier field is the unique device ID that we’re looking for. Go ahead and copy it to the Clipboard. You’ll need to paste it into the Provisioning Assistant shortly.

Starting the Provisioning Assistant

Next, head to the Apple website and the iPhone Dev Center (http://developer.apple.com/iphone). Make sure that you’ve logged in to the site, and then click the iPhone Provisioning Portal link, currently located in the upper-right side of the page. The Provisioning Portal is designed to give you access to the tools you need to create provisioning and distribution profiles. It also includes the Development Provisioning Assistant, which is the web utility that will make our lives much easier. Click the Launch Assistant button (see Figure 2).

Figure 2. Head to the iPhone Provisioning Portal, and then launch the Development Provisioning Assistant.


The assistant will launch in your web browser and display a short splash screen. Click the Continue button to begin.

Choosing an App ID

Your first step is to choose an App ID. This ID will identify a shared portion of the keychain that your application will have access to.

Come again?

The keychain is a secure information store on the iPhone that can be used to save passwords and other critical information. Most apps don’t share a keychain space (and therefore can’t share protected information). If you use the same App ID for multiple applications, however, they can share keychain data.

For the purposes of this book, there’s no reason the tutorial apps can’t share a single App ID, so create a new ID named anything you want. If you have already created App IDs in the past, you’ll be given the option to choose an existing ID. I’m creating a new App ID, Tutorials, as shown in Figure 3. Enter the ID and click Continue to move on.

Figure 3. An App ID can be used for a single application or group of applications.


Assigning a Development Device

Next you are asked to assign a development device, as shown in Figure 4. This device ID identifies which iPhone will be allowed to run the applications you create. Enter a meaningful description for the device (“Johns iPhone,” for example), and then paste the string you copied from the Xcode organizer into the Device ID field. Click Continue to move on.

Figure 4. Assign a device that can run your application.


Note that as with the App IDs, if you’ve already used a device ID in the past, you will be given the option of simply selecting it from a drop-down list.

Generating a Certificate Signing Request

Now things are getting fun. The next step takes place outside of your browser. Leaving the Development Provisioning Assistant open, go to the Applications/Utilities folder on your hard drive and open the Keychain Access utility. Choose Keychain Access, Certificate Assistant, Request a Certificate from a Certificate Authority from the menu (see Figure 5).

Figure 5. In this step, you create a certificate request that is uploaded to Apple.


The Keychain Access Certificate Assistant will start. Thankfully, this is a pretty short process. You just need to enter your email address, name, and highlight the Saved to Disk option, as shown in Figure 6.

Figure 6. Enter the information needed for the certificate request. You can leave the CA Email Address field empty.


Click Continue to save the certificate to your disk. Make sure you make a note of where you save the certificate, because you’re going to be uploading it to Apple back in the Development Provisioning Assistant. Once you save it, you can close the Certificate Assistant window.

Uploading the Certificate Signing Request

Return to the Development Provisioning Assistant in your web browser. Click Continue until you are prompted to submit the certificate signing request that you just generated (see Figure 7). Click the Choose File button so that you can select the request file, and then click Continue to upload it.

Figure 7. Upload the certificate signing request to Apple.


Naming and Generating the Provisioning Profile

We’re almost done! After uploading the request, you’ll be prompted to name the provisioning profile (see Figure 8). Because this profile contains information that can potentially identify individual phones and applications, you should choose something relevant to how you intend to use it. In this case, I’m only interested in using it as a generic development profile for all of my apps, so I’m naming it iPhone Development Profile. Not very creative, but it works.

Figure 8. Name the profile to reflect how you intend to use it.


Click the Generate button to create your provisioning profile. This may take 20 to 60 seconds, so be patient. The screen will eventually refresh to show the final profile information, as shown in Figure 9.

Figure 9. After several seconds, the profile is generated.


Our final steps will be downloading and installing the profile, and downloading and installing a security certificate that will be associated with the profile.

Downloading the Development Provisioning Profile and Certificate

At this point, your profile has been generated, along with a security certificate that can be used to uniquely associate your applications with that profile. All that remains is downloading and installing them. Click the Continue button to access the provisioning profile download screen, as shown in Figure 10. Click the Download Now button to save the profile to your Downloads folder (file extension .mobileprovision).

Figure 10. Download the provisioning profile.


As much as I hate to say it, the next thing to do is to ignore the onscreen instructions—the installation process that Apple describes in the assistant isn’t the most efficient route. Instead, click the Continue button until you are given the option of downloading the development certificate, as shown in Figure 11.

Click the Download Now button to download the certificate file (file extension .cer) to your Downloads folder. You are now finished with the Provisioning Assistant and can safely exit.

Figure 11. Download the development certificate.


Installing the Development Provisioning Profile and Certificate

To install the profile and certificate, we just need to exercise our double-click skills. First, install the development certificate by double-clicking it. Doing so opens Keychain Access and prompts you for the keychain where the certificate should be installed. Choose the login keychain, and then click OK, as demonstrated in Figure 12.

Figure 12. Choose the login keychain to hold your development certificate.


After adding the certificate, you should be able to browse through your login keychain for a key labeled with your name that contains the certificate.

To install the development profile, double-click the downloaded .mobileprovision file. Xcode will launch—if it isn’t already running—and silently install the profile. You can verify that it has been successfully installed by launching the Organizer within Xcode (Window, Organizer) and then clicking the Provisioning Profiles item within the iPhone Development section, as shown in Figure 13.

Figure 13. If the profile has been successfully installed, it should be listed in the Xcode Organizer.


Did you Know?

After you have a development machine configured, you can easily configure other computers using the “Developer Profile” item in the Xcode organizer. The “Export Developer Profile” and “Import Developer Profile” buttons will export (and subsequently import) all your developer profiles/certificates in a single package.


But Wait... I Have More Than One iOS Device!

The Development Provisioning Assistant helps you create a provisioning profile for a single iPhone, iPad, or iPod Touch device. But, what if you have multiple devices that you want to install onto? No problem. You’ll need to head back to the iPhone Provisioning Portal and click the Devices link on the left side of the page. From there, you can add additional devices that will be available to your profile.

Next, click the Provisioning link, also on the left side of the page, and use the Edit link to modify your existing profile to include another iPhone, as demonstrated in Figure 14.

Figure 14. Add additional devices to a provisioning profile within the web portal. Remember to redownload the profile and install it!


Finally, you’ll need to click the Download link to redownload the modified profile and then import it into Xcode so that the additional device is available.


Testing the Profile with an iPhone App

It seems wrong to go through all of that work without some payoff, right? For a real-world test of your efforts, let’s actually try to run an application on your iPhone. If you haven’t downloaded the project files to your computer, now is a good time to visit http://teachyourselfiphone.com and download the archives.

Within the Hour 1 Projects folder, open the Welcome folder. Double-click Welcome.xcodeproj to open a simple application in Xcode. After the project opens, your display should be similar to Figure 15.

Figure 15. Open the Welcome.xcodeproj in Xcode.


Next, make sure that your iPhone is plugged into your computer. Using the menu in the upper-left corner of the Xcode window, choose Device 4.0 (or a later version, if available). This will tell Xcode that when the project is built it should be installed on your iPhone. Finally, click Build and Run.

Xcode will install the correct provisioning profile on your device, and, after a few seconds, the application should be installed and launched on your iPhone, as seen in Figure 16.

Figure 16. Congratulations, you’ve just installed your first home-grown iPhone application!


You can now exit Xcode and quit the Welcome application on your iPhone.

By the Way

When you clicked Build and Run, the Welcome application was installed and started on your iPhone. It will remain there until you remove it manually. Just touch and hold the Welcome icon until it starts wiggling, and then delete the application as you would any other. Applications installed with your development certificate will stop working when the certificate expires (120 days after it was issued).



Other  
 
Video
Top 10
Home Theatre Pc Software And Operating Systems (Part 4) - XBMC
Home Theatre Pc Software And Operating Systems (Part 3) - Setting Up Windows Media Center
Home Theatre Pc Software And Operating Systems (Part 2)
Home Theatre Pc Software And Operating Systems (Part 1) - Windows Media Center
Nokia's Extreme Megapixel Bid
Storage, Screens And Sounds (Part 3)
Storage, Screens And Sounds (Part 2)
Storage, Screens And Sounds (Part 1)
Microsoft ASP.NET 4 : Using the SqlProfileProvider (part 4) - The Profile API, Anonymous Profiles
Microsoft ASP.NET 4 : Using the SqlProfileProvider (part 3) - Profiles and Custom Data Types
Most View
Managing and Administering SharePoint 2010 Infrastructure : Using Additional Administration Tools for SharePoint
Binding Application Data to the UI objects in Silverlight
iPhone Application Development : Getting the User’s Attention - Generating Alerts
Understanding and Using Windows Server 2008 R2 UNIX Integration Components (part 2)
iPhone Application Development : Creating and Managing Image Animations and Sliders (part 3) - Finishing the Interface
Cisco Linksys X3000 - The Link to Connectivity
HP LaserJet Pro CM1415fnw - Print from The Clouds
Building Your First Windows Phone 7 Application (part 2) - Using Your First Windows Phone Silverlight Controls
Determine Your Need for Server Core
Mobile Application Security : Bluetooth Security - Overview of the Technology
Using System Support Tools in Vista
Windows 7 : Using Windows Live Calendar (part 3) - Scheduling Appointments and Meetings & Viewing Agendas and Creating To-Do Lists
Advanced ASP.NET : The Entity Framework (part 3) - Handling Errors & Navigating Relationships
Graham Barlow: the Apple view
Ipad : Presentations with Keynote - Adding Transitions (part 2) - Object Transitions
Windows Server 2003 : Troubleshooting Group Policy
Microsoft XNA Game Studio 3.0 : Controlling Color (part 2)
Building the WinPE Image
Programming the Mobile Web : HTML 5 (part 3) - Offline Operation
Windows Phone 7 Development : Using Culture Settings with ToString to Display Dates, Times, and Text