Thursday 13 January 2011

Installing an archived application to an iPhone from XCode Organizer


The organizer window in Xcode has a handy feature where all the versions of applications you have submitted to the App Store are listed.
Today I needed to install an old version of an app to my iPhone in order to reproduce an issue a customer was having. It wasn’t as easy as I was expecting so I thought it was worth recording the process. Essentially you cannot simply copy the archived app to your device manually, as it was signed using the App Store certificate. We need to re-sign it using an Ad Hoc certificate instead - then it’ll run.
First up you need to make sure that you have an Ad Hoc distribution certificate handy, and that said certificate includes the device that you’re trying to distribute to.

UPDATE: August 2012: This process is far easier if you use this free open-source app called iResign.  This great app lets you take an existing IPA and re-sign it with your own certificate. Much, much simpler

Making the Ad Hoc Certificate
Ignore this part if you already have an Ad Hoc distribution certificate.
  1. Get your team agent to log into the iOS provisioning portal
  2. Go to provisioning / distribution tab
  3. Hit New Profile
  1. Choose ‘Ad Hoc’ as the distribution method
  2. Choose the relevant app ID (I chose an app id that allows any application by Calvium)
  3. Select the devices you want to be able to run on. I just chose all by selecting the select all button.
  4. Hit ok. Wait a minute or so, and hit refresh to be sure that the certificate is ready.
Re-signing the app using the Ad Hoc Certificate
  1. Go back to Xcode organizer. Open the ‘archived application’ section and choose the app you want to use.
  2. On the right-hand panel, choose the version to use. I’ve chosen 1.2. Apologies for the censorship in the images here..
  1. Click Share
  1. Click the ‘identity’ drop-down and under the heading ‘Ad Hoc Distribution’, select ‘iPhone Distribution’
  2. Now click ‘Save to Disk’
  3. Choose a filename (doesn’t matter what it is)
  4. Xcode will grind away for a bit re-signing the app, and then save a .ipa file containing the app.
Installing the app on your device (the .ipa file)
There are various ways of installing the ipa on the device, including via iTunes. I find this method by far the easiest - no syncing required.
  1. Open Xcode organizer again
  2. Attach the device
  3. Open the ‘Devices’ section, and select the device
  1. Under the Applications box, click the + arrow.
  2. Select the .ipa file you just saved, and lo and behold the app will be installed
  3. If it fails with an ‘no provisioning profile found’ or ‘invalid entitlements’ or similar, check that the ‘Provisioning’ box above contains the Ad Hoc profile you created earlier. If not, download it from the iOS provisioning portal, and manually upload it by clicking the + button under provisioning.

1 comment:

  1. xcode 7 now lets you sign the ipa during the export process when the archive is first converted to an ipa. I was pleasantly surprised at how easy it was, since usually doing anything with xcode, especially signing, is not.

    ReplyDelete