How to Deploy your App on an iPhone

So you’ve been developing your app and testing it on the iPhone simulator. However, did you know that there could be bugs that only show up when your app is running on an actual iPhone or iOS device?

Furthermore, testing your iOS app on a device is the best way to gauge performance issues before you go too far down the road.

For those of us who don’t have actual iOS devices, the iOS simulator is actually really good. But if you have a spare device lying around and you have enrolled in the Apple iOS developer program, then this tutorial will show you how to put apps on the iPhone or other iOS device.

Why do we have to go through all this trouble?

It’s common to wonder why it takes so many steps just to put your app creation on a real device. The answer is really about security. Although you might not create malicious apps to put on peoples phones, Apple cares that it can identify who created the app and that it can tell if the app has been tampered with or not.

These security measures are ensured by a process known as code signing. When you create an app package (binary) to put on a device, you have to put your “digital signature” on it by code signing it. Otherwise, Apple won’t let that app be deployed on any device.

– You’re going to need to enroll in the Apple iOS developer program which is $99 a year.
– You’ll also need an actual iOS device.

Request your certificates

Your certificate is used to code sign the apps and they uniquely identify you. In this step, we have to generate and request two certificates: one for development and one for distribution. We only need to do this once (not for each app!).

The development one is used for testing while the distribution certificate is used to sign your app bundle for distribution in the App Store once it’s ready.

Now that you’re enrolled in the Apple developer program, you can launch Xcode 5 and go to your preferences menu. Then go to the “Accounts” tab.

Fill in your Apple iOS developer account details here.

Xcode 5 accounts panel

Once you’re signed in, click “View Details…” and you’ll get to this panel where you can see your existing certificates and provisioning profiles.

If you click the “+” icon below the certificates pane, you can request a new iOS Development Certificate. Go ahead and do that now.
Also do the same thing and request an iOS Distribution Certificate as well.

Requesting an iOS development certificate in Xcode 5

Afterwards, if you login to your your iOS provisioning portal and go to “Certificates”, you can see that it’s actually been created!

In the past, this used to be a lot more tedious and you’d have to go through multiple steps to generate the request on your computer and then upload it to Apple through the provisioning portal. It’s nice that it’s integrated into Xcode 5 now!

iOS provisioning portal certificate

Before we can install the app on our device for testing, we’ll need to do a few things:
1. Configure the device for development and add the device to the member center
2. Create a provisioning profile for your app
3. Make sure your app is set to use that provisioning profile
4. Finally deploy the app to the device

This may seem really tedious (and it kinda is), but the reason for it is that the Xcode provisioning profile defines several key pieces of info such as what devices are allowed to install your app, an App ID to identify it with what’s registered in the portal and the development certificates.

The profile gets installed onto the device and then you’ll be able to deploy your iOS app to it.

Once we go through it, you’ll understand that it’s quite straight forward!

1. Configure the device for development and add the device to the member center

All we need to do here is plug in the iPhone or iPad to your computer with the USB cable.

This will usually launch iTunes and the thing to watch out for is that if your device is new, iTunes will ask you to set it up as a new device or restore a backup.

You have to get past this step or else it interferes with what we’re going to do in Xcode 5 to configure the device.

So make sure that your device is ready by seeing a screen like this in iTunes:

Connecting your iOS device to iTunes

If your iTunes window is asking you to set up the phone, you want to do it!

Next, you want to go back to Xcode 5 and go into your Organizer window by either pressing SHIFT+CMD+2 or using the menu option here:

Xcode 5 organizer menu option

Click the Devices tab at the top of the Xcode Organizer window. Then along the left hand side, you’ll see the device that you have connected (along with all the previous devices you’ve connected before).

Choose the currently connected device from the list.

You’ll see a screen like this and you want to click the Use For Development button. After it finishes configuring the device for development, click the Add To Member Center button. If you don’t see a Use For Development button, then it means that this device has been used for development before and you just need to add it to the member center.

Xcode 5 organizer use for development button

When you click the Add To Member Center button, it’ll ask you to choose an account. The one that you added earlier should show up. Select that one and click “Choose”.

2. Create a provisioning profile for your app

Next, login to your iOS Provisioning Portal; it’s time to create the App ID and iOS provisioning profile for your app!

Remember when you set up a new Xcode 5 project and you had to fill in a product name and a company identifier and both of those came together to form your bundle identifier? Well that comes into play now!

Xcode 5 new project bundle identifier

In your provisioning portal, go to the App IDs section.

Provisioning portal adding a new app id

Give your app a name and then scroll down a little to the explicit app id section and put in the same bundle identifier that you had set up for your Xcode project.

Setting an explicit app id

Then click “continue” and on the following confirmation screen, click “submit”.

Now go to the development provisioning profiles section. We’re going to create a new development iOS provisioning profile for the new App ID we just added.

Choose iOS App Development for the type and click “continue”.

Type of provisioning profile

On the next screen, choose the App ID that you just added in the drop down.

Select an app id for the new provisioning profile

On the next screen, select the development certificate and click “continue”.

Select the development certificate for the provisioning profile

Now, finally you can select the devices that your app is allowed to be installed on so select the one that you added earlier through the Xcode 5 Organizer.

Select devices for the provisioning profile

On the final screen, you can give the provisioning profile a name and generate it.

Name the profile and generate it

Click the blue Download button and the profile will be downloaded onto your computer. Go to the location where you saved it and then double-click the provisioning profile.

You may notice that there’s a provisioning profile expiration date. When the time comes, you can renew provisioning profile by going to where your profiles are listed and click “renew” beside the one that’s going to expire.

3. Make sure your app is set to use that Xcode provisioning profile

We’re almost ready to deploy the app onto our iOS device! The last step is to make sure that our app is set to use this new profile.

It’s crucial that your Xcode project bundle ID matches the bundle ID that you specified when you created your App ID or else you won’t be able to use this provisioning profile for this app.

Go to your Xcode 5 organizer and check that the profile is installed on your device by going to the “provisioning profile” section under your device in the Organizer.
(This can also be a great way to resolve “provisioning profile can’t be found” error messages)

provisioning profile installed on device

Next click on the root project node in your Xcode file navigator and on the right pane you’ll see the settings for your project.

Click the Build Settings tab and scroll down to the Code Signing part.

Xcode 5 build settings: code signing

You want to make sure that the code signing identity is set to use the certificate you created in the first step.

If you’re doing testing and development, you’ll want to select “iOS Developer” and if you’re signing to distribute your app to the App Store, you’ll want to choose “iOS Distribution”.

Both of these settings are automatic settings, meaning they’ll automatically select the signing identity to use. If you’ve only got one development and one distribution signing identity (which is most likely since you just requested one of each in step 1), then this automatic setting is ok, but if you have multiple signing identities then it may be best to explicitly select the signing identity that you want to use.

Selecting code signing identities

While you’re in the build settings, one thing to keep in mind is that when you create an Xcode 5 project, it defaults to a minimum deployment target of iOS 7.

That means that the device that you deploy the app on must be at least running iOS 7.0.

Settings if you want to include iOS 6 for deployment

In this example, I connected my iOS 6 device so I need to change my project settings to have a minimum deployment target of 6.0.

build settings: iOS deployment target

The architecture setting needs to be changed as well if you set your deployment target to 6.0. (note: you only need to do this if you set your deployment target to 6.0)
Architecture for iOS6

4. Finally deploy the app to the device

Now if everything is set up correctly, you’ll see the name of your phone in the list of deployable targets.

Selecting your device to deploy to

If you only see “iOS Device”, it won’t work. You’ll need to actually see the name of your device in the list.

So select your device and run the project to deploy the app on your phone!

Running the app on my iPhone!


Don’t see your device name on the list of deployment targets?

It can be really frustrating because there are so many steps in different places.

My advice would be to retrace your steps and make sure that you didn’t miss anything.

The first thing to try is to disconnect your device and then reconnect it. Then check the following steps.

1. You don’t need to request new certificates if you can see them in your provisioning portal.
2. Plug in your device and re-add it to the member center through the Xcode 5 organizer.
3. In the portal, double check that the App ID you created matches the one in your project.
4. In the portal, double check that the provisioning profile includes the device you have connected.
5. Re-download it and double-click it.
6. Go into your Xcode Organizer and under the connected device, in the provisioning profiles section, make sure you see the profile.
7. In your project build settings, make sure that your code signing settings are using the proper signing identities.
8. In your project build settings, make sure the deployment target is lower than the iOS version that your connected device is running.
9. Go to iTunes and make sure it’s not asking you to set up a new phone or restore a back up (this can interfere).


It can be pretty tedious to set up for the first time but for future projects, you only need to create new App IDs and new provisioning profiles without worrying about the other stuff.

In the next article, I’ll show you guys how to submit and publish an app into the App Store.

Thanks for reading this far and if you found it helpful, please help me out by sharing it using the social buttons below. Thanks!