The first thing you'll need for ad hoc distribution through Xcode is membership to the Apple developer programme and a valid iOS Distribution certificate. To view this certificate you need to:
- navigate to the Organizer in Xcode and click on the Devices tab
- select the name of your team from the left sidebar
If you don't see any certificates there with green ticks, then you need to go to the iOS Provisioning Portal in the Apple developer site. Once here:
- click on Certificates from the left side bar in your web browser and select the Distribution tab within this area
- if you have a certificate that isn't valid (most likely because you didn't copy it from another machine into your keychain), then you'll have to either copy the certificate and key to your new machine from the old one or revoke the old certificate and create a new one
- if there's no certificate then simply create one
- once you have a certificate you should be able to refresh Xcode inside the Team tab and the certificate will appear.
Once your distribution certificate is in place:
- go to the Provisioning option in the provisioning portal sidebar on the web
- click on the Distribution tab
- click New Profile
- select Ad Hoc for the Distribution method
- give your profile a name, it doesn't matter what it is
- next you'll need to supply your App ID, you can either use your iOS Wildcard or create an App ID in the provisioning portal that can be used here. (Note: if you choose to create an App ID then the bundle identifier you use in the provisioning portal will need to be the same as the one used in the Target summary for your app in Xcode.)
- underneath the App ID you will see a list of devices, these are either added by the devices having been plugged into Xcode or added through the provisioning portal - for which you'll need the device's UDID number and the owner's email address - tick the ones you want to be able to use the app you're distributing
Now return to Xcode
- within the Devices tab of the Organizer select from the left sidebar under Library "Provisioning Profiles"
- click the Refresh button and having supplied your developer account log-in details you should see the distribution certificate appear
Now to assign this profile to your project's build settings:
- select your Project's Info Settings add a configuration and call it "AdHoc"
- select the icon under Targets and go to the Code Signing section and change the AdHoc entry's settings to the name of the Provisioning Profile you created
Now to build the ipa:
- without your device plugged in, choose to Run your app on the iOS Device (from the pull down menu next to the stop button) BUT don't press Run
- from the Product menu (OS X menu bar) select Edit Scheme ...
- select Archive from the dialog box sidebar
- select your AdHoc Build Configuration from the drop down menu and then click OK
- go to the Product menu again and select Archive and then press OK
Once the archive process is complete you should automatically be taken to the Organizer Archives tab in Xcode. From here:
- Click Distrbute..
- Select "Distribute for Enterprise or Ad-Hoc Deployment"
- Press Next
- The Code Signing Identity that you need should already be selected but if not look for the name of your team underneath the correct iOS Distribution Provisioning Profile and select this (it should have the word "iOS Distribution" in brackets after your team name)
- click Next and it will ask you the name and location on your system where you wish to place the file
All is now finally ready, but you need one last thing:
- click on Devices tab in Organizer
- select Provisioning Profiles from the sidebar and highlight the one you've used for the app, then export the certificate
- send this mobile provisioning certificate with the app, since the person installing the app will need to drag the ipa and the mobile provisioning certificate into iTunes before syncing.