Sunday, June 21, 2009

New iPhone + New Apple Developer Provisioning Profile

Yesterday, I took some time off from the nice weather and gardening tasks to go out and get a new iPhone 3GS. First off, let me say that the speed difference is really great! I've only played around with a few of the new features (such as the video camera and compass), but the speed increase is a huge plus. Today, I got around to creating a new developer profile for my new iPhone 3GS. My old iPhone was having some problems a few months ago and Apple replaced it, so I remembered the hassles I had then setting up a new provisioning profile for the replacement device (this seems to be a common iPhone developer complaint). I had similar problems this time with the 3GS, so I've decided to note down all the things that I did to get it setup properly. Hopefully, this will help someone else (or, at least, it might remind me of the necessary steps the next time I have to do it!). Not all these steps may be necessary (and it's probably a lot easier if you're just adding a device to an existing profile rather than replacing a provisioning profile); however, I wanted to make sure I knew all the steps this time and it's what worked for me!

When you upgrade to a new device, you need to do the following:

In Apple's iPhone Developer Program Program Portal:

  1. Create a new provisioning profile for the device
  2. Set up a new device profile
  3. Download the new provisioning profile to the Desktop

On the Mac:

  1. Delete the old provisioning profile from ~/Library/MobileDevice/Provisioning Profiles/
  2. Drag the new provisioning profile from the Desktop into ~/Library/MobileDevice/Provisioning Profiles/

In the Organizer window in Xcode:

  1. Click on the device (in the left-hand pane)
  2. Drag the new provisioning profile into the "Provisioning" box
  3. Click on the "Provisioning Profiles" (in the left-hand pane)
  4. Double-click on the new profile name (in the top pane) - it should appear in the "Included Devices" bottom pane with an "Installed" status
  5. Close the Organizer window
  6. Press the Xcode/Empty Caches... menu option
  7. Close Xcode

On the Mac and iPhone:

  1. Power off both the Mac and the iPhone
  2. Power on both the Mac and the iPhone
  3. Attach the iPhone to the Mac

For each project you previously built with the old provisioning profile:

  1. Right-click on the [projectname].xcodeproj file and select "Show Package Contents"
  2. Make a backup copy of the project.pbxproj file
  3. Use a text editor (I used Emacs) to edit the project.pbxproj file:
    1. Delete any lines that have the key CODE_SIGN_IDENTITY
    2. Delete any lines that have the key PROVISIONING_PROFILE
    3. Delete any lines that have the key "CODE_SIGN_IDENTITY[sdk=iphoneos*]"
    4. Delete any lines that have the key "PROVISIONING_PROFILE[sdk=iphoneos*]"

In Xcode, for each project you previously built with the old provisioning profile:

  1. Open the project
  2. Press the Build/Clean All Targets menu option
  3. Press the Project/Edit Project Settings menu option
  4. On the Build tab under "All Configurations", chage the "Code Signing Identity" value to iPhone Developer
  5. On the Xcode dropdown menu, select to build on the Device
  6. Press the Build/Build and Run menu option (the application should build and load on the device)

That's what worked for me. If anyone has an easier/alternative approach, let me know and I'll publish relevant comments in updates to this post.

0 comments: