Line In

Nomadic Designer

Handling Provisioning in Xcode 4.3

Provisioning your device is an important part of the development process. Unfortunately, it can also get a little messy (although Apple has taken steps to clean it up a bit).

There are basically 3 parts:

  1. Adding your certificate
  2. Adding App IDs
  3. Generating your provisioning profile

Setting up Your Certificates

This one is relatively straightforward—Xcode will go get it for you.

First, you have to enrol in the iOS Developer Program. Once you’ve paid up and been sent your emails, you can get a certificate direct in Xcode:

  1. Open up Xcode if it isn’t already open
  2. Go to the `Organiser` and click `Library`
  3. Click on Provisioning Profiles and then, in the bottom right, click `Refresh`
  4. Enter your Apple ID and password
  5. Xcode will then see that you haven’t got your certificate and ask you if you want to create one. Hit `Submit Request`.

Your App IDs

You can have as many app IDs as you want but be aware that you cannot delete them once created, so if, say you make a spelling mistake when you’re creating one then you can’t edit the name or delete it afterwards.

  1. Log in to the Apple Developer portal
  2. Go to the Member Center
  3. Click on ‘iOS Provisioning Portal’
  4. Click on App IDs
  5. Click on New App ID
  6. Give it a name. This name is for your reference.
  7. Give it a bundle identifier. The common syntax is to use reverse domain name (e.g. `com.yourdomain.my-fancy-app`)

Once created, it cannot be deleted. You can create a new one, but not with the same bundle identifier.

When it’s created, you’ll see a long list of additional configuration options. If you click Configure, you can add support for iCloud and Push Notifications, should you need them.

Please note you will need to set this up even if you just want to test iCloud (which can only be tested on provisioned devices).

Provisioning

Now comes the slightly more complicated part: Provisioning

First, you need to decide what you want to do.

Just Test It on Your Own Device

  1. Under `provisioning -> development` click `New Profile`
  2. Give the profile a name
  3. Select the certificate you want to use (there might just be one)
  4. Select the App ID you created above (and now you can see why it’s important to give them all unique names)
  5. Select the devices that you want to run it on (there might just be one)

You should note that this is not an Ad-Hoc profile. Even if you select more than one device, you can only test your app on that device if it is connected to Xcode and has been set up for development.

Send it Out For Testing

  1. Under `provisioning`, click the `Distribution` tab
  2. Select `New Profile`
  3. Select `Ad Hoc` as the distribution method
  4. Select the App ID you created for your app
  5. Select the devices you want to run it on

Preparing it for the App Store

  1. Under `provisioning`, click the `Distribution` tab
  2. Select `New Profile`
  3. Select `App Store` as the distribution method
  4. Select the App ID you created for your app

Getting Your App On Devices

Now you’ve created all of your profiles, you can access them directly via Xcode. You can actually also create profiles via Xcode, instead of using the developer portal.

  1. Open up Xcode if it isn’t already open
  2. Go to the `Organiser` and click `Library`
  3. Click on Provisioning Profiles and then, in the bottom right, click `Refresh`
  4. Sign in to the Apple Developer Center using your developer credentials

Xcode will download a list of all of your current provisioning profiles, which you can drag directly into devices that are connected or, if you’re using Ad Hoc distribution, you can export them to be sent along with the app.

Signing Your App

Before you’re ready to distribute, you need to check that the correct profile is being used in your Build Settings.

Select your app target, then click Build Settings and make sure that, under Code Signing Identity, it has your developer certificate (and not Don't Code Sign).

For iCloud and Push Notifications, you’ll also need to make sure that it is referencing the correct Provisioning Profile. Click the double arrow next to Code Signing Identity and select the correct identity for your current app.

Application Failed Codesign Verification

If you get this error while building for Release (building for Debug won’t cause this error):

Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)

It’s likely that:

  1. You’ve not signed your app (see signing your code, above); or
  2. You’ve only added a Development Provisioning Profile. You need to create a separate provisioning profile for distribution (see “Preparing it for the app store”, above), download it and use this as your code signing profile

Also note that Xcode generates your Bundle identifier automatically and I believe (but I may be wrong here) that, if the generated identifier is different to the Provisioning Profile identifier in any way (including capitalisation), you might need to enter it manually. To do this:

  1. Select your target
  2. Under `iOS Application Target`, make sure that this is the same as your Profile identifier.
  3. If you need to, you can go to the `info` tab and change the `Bundle identifier` property under `Custom iOS Target Properties` in the Plist directly. Make it match your Profile identifier.

When you’re first starting out, this can all seem like a bit overwhelming but if you go through things one step at a time, starting with the Certificate, then you’ll be fine.