Tuesday, 19 November 2013

You Want to be an App Developer? Deploying Your iOS App to a Device

So You Want to be an App Developer? Deploying Your iOS App to a Device



As a beginning developer, it is useful to play with your first app on the iOS simulator.  But your enthusiasm and desire to learn more often greatly increases once you deploy the app to your iPone .  You can customize a sample project and show your friends an app they can’t get.  Or you can create a utility for yourself that does something you can’t get from a free app — a flashlight with morse code anyone?
If you’ve successfully completed the tasks in my last article(click here )and you’re ready to take the next step, this article is for you.  Even if you haven’t, this article details everything you need.


What you will need

  • A Macintosh computer with OS X Lion or Mountain Lion.
  • An iPhone or iPad with iOS 43 or higher.
  • Xcode 4.5 or higher.  Download or update to the latest version here.
  • Sample code.  I’ve created a .zip file containing a project you can import directly into Xcode, which you can download here.
  • iOS developer account, which costs $99/year.  Register for it here                                         

What Xcode and your iPhone need

The basic components needed to deploy an app to your iPhone are as follows:
  • A Development Certificate, which you use to sign apps.
  • One or more devices registered on the iOS Developer .
  • An Application ID, which is a string of text that uniquely identifies a specific app of yours (e.g. com.yourcompany.yourapp) or a group of apps (e.g. com.yourcompany.*).  For development we use a Wildcard App ID (*), which you can use to deploy any sample project that you download from the web.
  • A development Provisioning Profile: a file that essentially contains all of the above, and is installed on your device so that it will allow your app to be launched.
Prior to Xcode 4.0, you had to log on to the iOS Developer Portal to create and install these yourself.  Now Xcode does almost all of this for you.  Before we get started though, make sure you’ve verified that your username and password can log on to the iOS Developer Portal, because there are points where Xcode will ask for this information.  Also, be aware that these instructions are for freshly configured development systems.  So if you encounter some trouble along the way, refer to this article on the Apple developer website for help.

Now let’s get started!

First, we need to create the Development Certificate using the following steps:
  • Open Xcode and select “Window->Organizer” from the menu.
  • Click the “Devices” button, then select “Provisioning Profiles” in the “Library” section.
  • Click the “Refresh” button at the bottom right.
During this process, Xcode will ask for your username and password for the Developer Account you created earlier.  Then it will ask you to submit a request one or more times for a certificate.
Xcode will then ask you to Export the newly created developer profile to a file.  This file can be used to recover your development certificate or to move your profile from one Mac to another.  So click Export and choose a filename and password, and keep it safe.
Now let’s provision your device.  Stay in the Organizer window and plug in your device.  When your device appears on the left, click it.  You should see a button titled “Use for Development,” which you should click.  If the button is not present, just click “Add to Portal” at the bottom.  This process not only registers your device, it also creates the Wildcard App ID and installs the provisioning profile on your device.
You’re now ready to deploy the sample project!
Open the attached Xcode project with File->Open if you haven’t already done so.  Just to the right of the Run and Stop buttons, you should see a button labeled “hello” followed by a device name, such as “iPhone 6 Simulator”.  Click this text and switch it to your iPhone or ipod.
Now, make sure your device isn’t locked, and click Run.  Here, Xcode may prompt you to allow access to yourkeygun (to sign the app), so click Always Allow and wait — soon your app will be running!
As with the simulator in the last article’s sample project, you should see NSLog statements appear in the Debug window, except now you may use your finger to press the button on your device and move it.  No more faking it with mouse clicks!
Finally, you’re up and running!  Try playing with the sample code — make changes, download other samples, or just have fun.

Other bits of information

The provisioning profile installed on your device expires within 90 days, but may be renewed regularly through Xcode as long as you keep your developer account active.  And when you’re ready to deploy an app to the app store, you’ll have to use an App ID that is not a wildcard.  This information can be found in the article referenced above and here.
Any luck or issues with this article?  Please post comments below.

No comments :

Post a Comment