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, iPhoLightning-Cable-and-iPhonene, 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!

  1. 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.Screen Shot 2015-12-23 at 2.11.16 PM
    • Select your device form the list on the left side of the window. Screen Shot 2015-12-23 at 2.17.07 PM
    • 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.)
  2. Register your device in the Apple Developer Member Center. Here are the steps to register your device:
    • Click on Certificates, Identifiers & Profiles.
      Screen Shot 2015-12-23 at 2.37.41 PM
    • Click on the Devices link.
      Screen Shot 2015-12-23 at 2.39.40 PM
    • Click on the + button to add your device to the list.
      Screen Shot 2015-12-23 at 2.42.45 PM
    • Enter a descriptive name and the device’s identifier string (UDID).
      Screen Shot 2015-12-23 at 4.17.39 PM
  3. 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:
      Screen Shot 2015-12-23 at 5.11.19 PM
    • 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.
      Screen Shot 2015-12-23 at 5.13.36 PM
    • Return to the online Apple Developer Member Center and view the iOS Provisioning Profiles. You should see your new provisioning profile as shown below:
      Screen Shot 2015-12-23 at 5.19.02 PM

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.

 

Advertisements

Entry filed under: iOS, Programming. Tags: , , , , .

Developing iOS Apps in Visual Studio with MacinCloud Testing Location-Aware Android Apps on an Emulator

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Bird’s Bits

Computers, software & the Internet

Recent Posts

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 41 other followers


%d bloggers like this: