Note: If you are having issues with archives that say “This kind of archive cannot be signed” and won’t let you create an IPA then please pay particular attention to the part of this post titled Skip Install.
With my recent upgrade to Xcode 4 I have run into some problems archiving my apps and creating ad hoc builds to distribute to clients. I think I finally have a handle on all the steps and thought I would share them here for your reference and mine.
Before we get into creating an ad hoc build I want to put in a word on distributing ad hoc builds in general. It used to be that the way to do this was to build your ad hoc app signed against your ad hoc distribution provisioning profile and then you would share both the .app file and the .mobileprovision file. The user would then have to drag the .mobileprovision file into the left bar in iTunes and do the same with the .app file. A much better way is to distribute an IPA file signed with the ad hoc distribution provisioning profile so that the user just has to double click the IPA file to install in iTunes.
To create an IPA file used to take a bit of work, but for some time now there has been a very handy way to do this directly in Xcode through the Archive (previously Build & Archive) option. When you Archive an app it puts the Archive into your Organizer where you can then choose to share the app as an IPA file and select a provisioning profile to sign it with. I have a wild card app ID that I use for all my development work and also to create the ad hoc distribution provisioning profile. I always give the distribution profile a generic name so that I can use it no matter who I happen to be working for.
Anyway, that is the big picture. Here are the details:
Note I am assuming you have already created and downloaded a distribution provisioning profile that includes the UDIDs of the people’s devices you are distributing to.
Make sure you have set an icon file to use
If you don’t have an app icon you can’t create an ad hoc distribution, so make sure you add one to your project and set its name in your Info.plist.
Create an Entitlements.plist
NOTE: This may still be required for distributions by TestFlight.
An Entitlements.plist file is no longer necessary with Xcode 4 per Technical Note TN2250. It says:
“Previous to Xcode 4.x, it was required that the developer create a Code Signing Entitlements file in the Application Bundle for Ad Hoc testing, that defines the entitlement “get-task-allow” with a value of “false” (un-checked). However with Xcode 4 that is no longer required so long as the application is shared via deferred signing on the Application Archives panel in Organizer. See the section Using the Build And Archive feature of Xcode for Deferred Code Signing for more information.
Furthermore, if you are receiving an error similar to:
The app 'Foo' was not installed on the iPhone "foobar's iPhone" because the entitlements are not valid.
Try removing the Code Signing Entitlements configuration from the Project and Target “Build Settings” tabs in Xcode 4, and then try your Ad Hoc build again.”
For posterity I am leaving the instructions for how to create an Entitlements.plist here, even if you no longer need it:
Right (or Option) click on the Resources folder in the Groups & Files pane and select New File… then in the iOS list select Code Signing, then Entitlements and hit the Next button.
The name of the file defaults to “Entitlements.plist” which is fine so just hit Save.
You used to have to edit the Entitlements.plist at this point but I haven’t found that to be necessary with Xcode 4.
Create a new configuration in your Project Settings
I always create an Ad Hoc Distribution configuration. Click on your project in the Groups & Files pane and then select your project in the column that shows your project and targets.
If you are not already on the Info screen, click the Info tab. Next click the ‘+’ button and select Duplicate “Release” Configuration.
Give the new configuration a name. I always name mine “Ad Hoc Distribution”. (I creatively name the one I submit to the app store “App Store Distribution”)
Setup your Target
Now select your Target (below your Project), make sure you are on the Build Settings tab and that you have all and combined selected and scroll down to Code Signing. Set the iOS SDK for your Ad Hoc Distribution to your generic ad hoc distribution provisioning profile, or if you only have the one distribution provisioning profile just set it to iPhone Distribution which will default to the one you have.
Just above this you need to fill in “Entitlements.plist” for the Code Signing Entitlements for your Ad Hoc Distribution.
If your project relies on a static library (such as cocos2d) then you need to do one extra step to make sure it gets included in the app binary correctly. In the left pane with your Project and Targets you need to select the static library and then in the right pane in its settings under Deployment, you need to set Skip Install to Yes for the Ad Hoc Distribution. (The same would apply for an App Store Distribution) NOTE: This is only necessary if your project contains static libraries and must be set on that static library, not your apps Target or your Project.
Set a configuration for your Archive scheme
In the drop down menu in your tool bar next to the Run and Stop button, select Edit Scheme. Select Archive in the left pane and then set the Build Configuration to your Ad Hoc Distribution and click OK.
Create the Archive
You are now ready to create your Archive. In the top menu select Product and then Archive. When it is complete you will be taken to the Organizer on the Archives tab.
Create the IPA
To create the IPA file, with the archive highlighted, click the Share button and then confirm the provisioning profile you want to use. If you only have the one distribution provisioning profile it should default to the correct one. Click Next and then give the IPA file a name and save it.
Now to distribute your ad hoc all you have to do is email the IPA file and instruct your client to double click the file and then sync their device.
Hope this helps some people migrating to Xcode 4 or even people just starting out.