Testing iOS Apps on Hardware Devices
March 7, 2016 at 6:34 am Leave a comment
Deploying Apps directly to devices
One of the trickier parts of doing iOS development is registering your device (iPad, iPhone, or iPod) with Apple so that you can test an app on that device. This process is called creating a provisioning profile. You can follow either the Apple guide or the Xamarin guide for doing this, but I’m writing my own guide because things didn’t go very smoothly for me while following either of theirs. (Although the Xamarin guide was easier to understand.)
I’m doing iOS development using Xamarin Studio, but the process for creating a provisioning profile is essentially the same if you are doing development with Xcode.
Prerequisite: Apple Developer Program Membership
First, you must join the Apple Developer Program. Note that you don’t need to join the Developer Program to test your app on a device that you connect to your Mac via a USB cable, you can use Apple’s free provisioning service. But you won’t be able to distribute apps to anyone else or submit them to the App Store.
There are several different types of developer memberships. All of them allow you to distribute apps to a limited number of other users for testing. However, if you are a member of the free iOS Developer University Program, then you will only be able to distribute your apps to other student and faculty developers who are members of the iOS developer team at your educational institution. In addition, you won’t be able to upload your app to the App Store. To do these things, you will need to pay for a $99 per year individual or organizational developer membership.
But, I’m assuming you already have an iOS developer membership of some kind and what I describe will be true for all of them.
Once you join the Apple Developer program, you will need to request an iOS Development certificate. You will do this through Xcode. First, you will enter your Apple ID in Xcode, then you will create a Signing Identity that will add a certificate (and associated keys) to your OS X keychain. The certificate will be visible in the Keychain Access app on your Mac. Once Xcode has synced with your developer account, you will be able to see your new (or pending) Developer Certificate online in the Apple Developer Member Center.
About Developer Certificates and Keys
Before we move on to provisioning your iPad or iPhone for app deployment (the main point of this post), we should talk about the sticky topic of certificates and keys. Earlier, I mentioned that a developer certificate is generated when you create a Signing Identity in Xcode. This certificate is validated using public-private key pairs. The certificate will have representation in two places:
- Online, in the Apple Developer Member Center: The key associated with your developer certificate online is the public key.
- On your Mac, in Xcode: Both a public and private key are stored in your OS X keychain. Caution: If you do development on more than one Mac, the one you used to request a developer certificate will be the one where your primary keys are stored. Before you use Xcode for iOS development on another machine you must export the development certificates from this machine and import them on the other one. For more information, read Maintaining Your Signing Identities and Certificates in the iOS Developer Library.
Registering an iOS Device for App Deployment
(Creating the Provisioning Profile)
Now we finally get to the heart of this post. I’m assuming you’ve already added the Apple ID for your developer account to Xcode and have created a Signing Identity. If you haven’t, read Managing Accounts in the iOS Developer Library. Now you can create a provisioning profile.
Well we’re almost ready. First, make sure that your version of Xcode supports the version of iOS on your device. I have iOS 9.2 on my iPad and had to upgrade xCode to version 7.2. If you get the error message “Could not find Developer Disk Image” when you try to build your app with your iOS device as a target, then you probably need to upgrade Xcode to the latest version.
A note on updating Xcode: For some reason, an update to version 7.2 did not show up in the App Store app under “updates”. I had to search for Xcode in the App Store and install it again. Here’s a link to Xcode in the App Store: https://itunes.apple.com/us/app/xcode/id497799835?mt=12.
Now we’re really ready!
- Get your iOS device’s identifier using Xcode. (If you want to send your app to someone who doesn’t have XCode, they can get their iOS device’s identifier using iTunes). Using Xcode, follow these steps:
- Connect the device to your Mac using a USB cable.
- Open the Devices window as shown below.
- Select your device form the list on the left side of the window.
- Copy the string shown in the “identifier” field.
(If you want to send your app to someone who doesn’t have XCode, they can get their iOS device’s identifier using iTunes.)
- Register your device in the Apple Developer Member Center. Here are the steps to register your device:
- Click on Certificates, Identifiers & Profiles.
- Click on the Devices link.
- Click on the + button to add your device to the list.
- Enter a descriptive name and the device’s identifier string (UDID).
- Click on Certificates, Identifiers & Profiles.
- Create a provisioning profile.
A provisioning profile is used by Xcode to configure your app to be launched on registered iOS devices. Provisioning profiles are created for a team not an individual. If you have an individual developer account, then you will be the sole team member. You will use Xcode to create a team provisioning profile. Follow the steps below.- Create a dummy application by clicking on File, New, Project (any kind of iOS project will do).
- Once the project is created, in the IDE (not on the main menu), click on General, expand Identity, and select your developer team from the Team drop-down list as shown below:
- You will see a warning, like the one below, saying that there are no provisioning profiles for this team. Click the Fix Issue button to create the provisioning profile.
- Return to the online Apple Developer Member Center and view the iOS Provisioning Profiles. You should see your new provisioning profile as shown below:
Congratulations! You have successfully created a provisioning profile! Now you can install apps you created on the device you provisioned. You can use Xcode or Xamarin Studio to create the apps, then deploy using a USB cable, or e-mail the app to your iOS device, or post the app on a web site, then download it to your device and install it.
Entry filed under: iOS, Programming. Tags: iOS, iPad, iPhone, Mobile, XCode.
Trackback this post | Subscribe to the comments via RSS Feed