Tutorial: Provision Your App to Run on a Device

One of the hardest things to figure out when starting iOS Development is how to work through the app provisioning process so you can test your app on a real device. In order to deploy your app on a device you need to belong to the iOS Developer Program. Visit http://developer.apple.com/programs/ios to signup. It costs $99/year for the standard program. This also includes a host of development tools, resources, technical support and distribution of your application via the Apple App Store when you’re ready to release.

Registering Your Device

Before you do anything, you’ll need an iOS Device, this can be an iPhone, iPod Touch or iPad. To register your device within the Provisioning Portal you need to find out the unique identifier (UDID) for your device. Plug your device into your Mac and open up Xcode. Select Window > Organizer. Choose your device from the left and you’ll see the details on the right. Copy the 40 character “Identifier” to your clipboard.Screen Shot 2013-08-06 at 8.49.00 AMNext login to the iOS Developer Center https://developer.apple.com/devcenter/ios/index.action. You should see the screen below.Screen Shot 2013-08-06 at 8.41.13 AMSelect Devices to see the list of iOS Devices you have registered. To add a new one click the + plus button in the top right. Enter a name for your device, i.e. “Brian’s iPhone5″. Paste your device Identifier into the UDID space and click “Continue”.Screen Shot 2013-08-06 at 8.49.19 AMOnce added, you should now see your device in the list.Screen Shot 2013-08-06 at 8.49.35 AM

Setup Your Developer Certificate

To sign development versions of your iOS App you need to have a certificate installed on your Mac. To begin, select “All” from under the Certificates section on the left. Just like adding a new device select the + plus button from the top right. Then choose “iOS App Development” under the “Development” section and click “Continue”.
Screen Shot 2013-08-06 at 8.50.30 AM Next you’ll need to create a Certificate Signing Request (CSR). Follow the directions on the screen below.Screen Shot 2013-08-06 at 8.50.44 AMOpen “Keychain Access”, this can be found within your finder under “Applications > Utilities” or by searching “Keychain Access” in Spotlight. Then select “Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority”. Screen Shot 2013-08-06 at 8.52.04 AMEnter your Email Address, Name and select “Saved to disk”, then click “Continue”.Screen Shot 2013-08-06 at 8.52.57 AMSave the Signing Certificate Request to your desktop.Screen Shot 2013-08-06 at 8.53.37 AMNext, go back to the iOS Developer Center and click the “Choose File…” button and select the file you saved to your desktop.Screen Shot 2013-08-06 at 8.54.08 AMYour certificate is now generated, so click the “Download” button to save it to your computer. Screen Shot 2013-08-06 at 8.54.42 AMFind the file within your “Downloads” directory and double click it to install it into the Keychain Access. You should be able to click the arrow to the left of the certificate to see the private key under it. If you see this private key then you’ve installed the certificate correctly, if not try creating the certificate again.Screen Shot 2013-08-06 at 8.55.33 AM

Registering Your App

With every app you want to run on your device you need to register it within the iOS Developer Center. Click “App IDs” from the left menu under the “Identifiers” section. Just like we’ve done before select the + plus button from the top right to register a new App ID. Enter the Name of your app (this is not the name you’ll see in the App Store but for you to identify your app in your list of apps. Then enter a unique Bundle ID. This cannot be changed after this screen. Use the reverse-domain name style, i.e. com.rogers.ledbaseball, then click “Continue”.Screen Shot 2013-08-06 at 8.56.21 AMReview your application details and click “Submit” to finalize your App ID. Screen Shot 2013-08-06 at 8.57.37 AM

Create The Provisioning Profile

Now that we have our device registered, your certificate installed and our App ID setup it’s time to link them together in a Development Provisioning Profile. Click “Development” from under the “Provisioning Profiles” section on the left menu. Then like before click the + plus button in the top right to create a new provisioning profile. Click “iOS App Development” under “Development” and click “Continue”.Screen Shot 2013-08-06 at 9.02.23 AMSelect the App ID that you just created from the dropdown list and click “Continue”. Screen Shot 2013-08-06 at 9.02.40 AMSelect the certificate that you have installed on your Mac and click “Continue”. If you belong to a team of developers you’ll see their certificates listed. If you have an Individual account you’ll just see the one you setup. Screen Shot 2013-08-06 at 9.03.07 AMSelect the devices that you would like to run the app on. It doesn’t hurt to “Select All”. If you need to add a new device in the future you will need to add the device to the iOS Developer Center, then update the Provisioning Profile to include the new device. Screen Shot 2013-08-06 at 9.03.34 AMNext enter a name for your Provisioning Profile. I like to add “Dev” to the end if it’s a Development Provisioning Profile and “Store” to the end if it’s a Distribution Provisioning Profile because it’s easier to distinguish them later in Xcode. Then click “Generate”. Screen Shot 2013-08-06 at 9.03.54 AMClick “Download” to save the new Development Provisioning Profile to your computer. Screen Shot 2013-08-06 at 9.04.18 AMFind the file within your “Downloads” directory and double click it to install it into the Xcode Organizer. You should then see the Provisioning Profile in the list of apps. If the status is “Valid profile” then the profile is setup correctly, if not then try starting from the beginning again.Screen Shot 2013-08-06 at 9.05.18 AM

Configure Your App

If you have a valid provisioning profile the rest should work with no problem. Open up the app that you want to install on your device in Xcode. Select the Info.plist under the Supporting Files group within the project. Change the Bundle Identifier to the App ID that you setup in the iOS Developer Center.Screen Shot 2013-08-06 at 9.06.43 AMNext click on the Project Settings and select “Build Settings”. Scroll down to the “Code Signing” section. Select the “Code Signing Identity” to see the dropdown. This dropdown lists all of the Provisioning Profiles installed on your computer. Select the name of the profile you just setup. Screen Shot 2013-08-06 at 9.07.23 AMDo the same with all of the options under “Code Signing Identity”. Ensure they are all selected to the app provisioning profile. Screen Shot 2013-08-06 at 9.07.42 AMNext click the Target of the App and select “Build Settings”. Just like you did for the Project Settings change all of the “Code Signing Identity” to the correct app Provisioning Profile. Note: If you do not see the new Provisioning Profile in the list, restart XCode and it should show up. Screen Shot 2013-08-06 at 9.07.52 AMDo the same with all of the options under “Code Signing Identity”. Ensure they are all selected to the app provisioning profile. Screen Shot 2013-08-06 at 9.08.11 AMThat’s it, now in the top left of the toolbar in Xcode, select the scheme dropdown to choose your iOS Device that’s plugged-in. Build and run your app and it should show up on your device. Now you can test your app on a real device and show it off!