To test an application on a Real IOS device, you have to enroll in the Apple developer program. After registering on the Apple developer account for free, you need to purchase the developer program to test apps on the real device. To Deploy Application to Real IOS Device
, we need to do the following tasks:
- Step 1: Create a Certificate Signing Request (CSR)
- Step 2: Create a Development Certificate
- Step 3: Add a Device
- Step 4: Create an App ID
- Step 5: Create a Provisioning Profile
- Step 6: Configure the Project
- Step 7: Add a Developer Account
Step 1: Create a Certificate Signing Request (CSR)
A certificate is an electronic document. It links your digital identity with other information, such as your name, email, and organization information. A development certificate consists of a secret private key and a shared public key.
Xcode uses the private key of the certificate to cryptographically sign your application binary. To obtain a development certificate, you first need to create a Certificate Signing Request or CSR.
You can create a CSR using OS X’s Keychain Access utility, which you can find in the Applications > Utilities folder. Open the Keychain Access menu, select Certificate Assistant and choose Request a Certificate from a Certificate Authority….
Fill the required information which you used while signing up the Apple Developer Program. Leave the certificate authority email address (CA Email Address) blank and make sure to check Saved to disk to save the certificate signing request to your machine. Leave Let me specify key pair information unchecked.
Click Continue, specify a location to save the CSR, and click Save. Browse to the location you specified to make sure the CSR was generated. In Keychain Access, under the Keys category, you can see that the private and public keys have been added to your login keychain.
Step 2: Create a Development Certificate
Open a browser and navigate to Apple’s Developer Website. Click Member Center at the top, sign in with your developer account, and choose Certificates, Identifiers & Profiles.
On the next page, select Certificates from the iOS Apps section.
Click the plus button in the top right to add a new certificate. From the list of options, choose iOS App Development. That’s the type of certificate we’re interested in. Click Continue at the bottom.
The next page describe the steps to create a CSR. Since we already have a CSR you can click Continue at the bottom.
Upload the CSR which you saved earlier in Step 1 and click Generate at the bottom.
That’s it. Click the Download button to download the development certificate. After downloading the development certificate, double click it to Install it in Keychain Access.
If Keychain Access prompts you to add the certificate to the login keychain, then you can safely click Add.
In Keychain Access, select My Certificates on the left and locate the certificate you added to make sure you’ve installed it correctly.
Step 3: Add a Device
You cannot run an iOS application on a random device. You need to specify which devices can run your iOS application by marking one or more iOS devices for development in the developer portal. Navigate to the Certificates, Identifiers & Profiles section of the developer portal, select the Devices tab in the iOS Apps section, and click the plus button in the top right.
To register a device, enter a name for the device and its UDID. The UDID is an identifier that uniquely identifies an iOS device. Note that the UDID is not the same as the device’s serial number.
You can find the UDID of a device by connecting the device to your machine, launching Xcode, and choosing Devices from the Window menu. The forty character alphanumeric string next to Identifier is the device’s UDID.
Step 4: Create an App ID
An App ID is an identifier that uniquely identifies an application on iOS. It’s much like the device’s UDID, which uniquely identifies a device.
The App ID of an application consists of your application’s bundle identifier prefixed with a unique ten character bundle seed ID generated by Apple. You implicitly specified a bundle identifier for your project by giving your application a name and specifying an organization identifier.
By default, the bundle identifier is your application’s name prefixed with your project’s organization identifier. You can change the bundle identifier to whatever you like. It’s recommended to adopt the reverse domain name notation, for example, com.tutsplus.my-first-application. The complete App ID would then be xxxxxxxxxx.com.tutsplus.my-first-application.
To Create a new App ID in the developer portal, navigate to the Certificates, Identifiers & Profiles section, click iOS Apps, and choose App IDs from the menu on the left. To create a new App ID, click the plus button in the top right.
Start by giving your App ID a descriptive name so you can find it later. Leave the App ID prefix field untouched. In the section App ID Suffix, enter your application’s bundle identifier. Make sure you enter it in the section labeled Explicit App ID.
You can also opt for a Wildcard App ID and replace the application name in the bundle identifier with an asterisk, for example, com.tutsplus.*. This is useful if you intend to create a suite of applications that need to share keychain access or don’t require keychain access at all. The asterisk or wildcard character needs to be the last component of the bundle identifier.
Step 5: Create a Provisioning Profile
With the development certificate and the App ID in place, it’s time to create a provisioning profile for your application. Before we start, it might be useful to explain what a provisioning profile is, because this is something that confuses many new iOS developers.
Apple’s documentation defines a provisioning profile as “a collection of assets that uniquely ties developers and devices to an authorized iOS Development Team and enables a device to be used for testing.” In other words, a provisioning profile contains the information that the operating system needs to verify whether an application is permitted to run on a specific device. This implies that the provisioning profile needs to be installed on each device the application needs to run on.
Let’s create a provisioning profile for your application. In the Certificates, Identifiers & Profiles section of the developer portal, select the Provisioning Profiles tab in the iOS Apps section. Click the plus button in the top right to create a new provisioning profile. Select iOS App Development in the Development section and click Continue.
In the next step, select the App ID you created a few minutes ago and click Continue.
Select the development certificate from the list of certificates to associate the new provisioning profile with the correct certificate. Click Continue.
You now need to select the devices you wish to link to the provisioning profile. Remember that only these devices will be able to run your application during development.
Give the provisioning profile a descriptive name so you can easily find it later. Click Generate and download the provisioning profile to your development machine. Double click the provisioning profile to add it to Xcode.
If you wish to add more devices to an already existing provisioning profile, then you can do so by editing the provisioning profile. All you need to do is download the new provisioning profile and install it on every device you wish to test with. In other words, you don’t need to create a new provisioning profile if all you want to do is add or remove devices.
Step 6: Configure the Project
Before you can build and run your application on your device, you need to update the build settings of the target in your Xcode project.
Open the Xcode project (Ex: SafariLauncher) and select the project from the Project Navigator on the left. Select your Application in the Targets section and open Build Settings at the top.
Scroll through the list and search for the Code Signing section. In this section, search for the Code Signing Identity subsection and set the Debug configuration to match iOS Developer. It’s usually located under the Automatic heading.
Step 7: Add a Developer Account
Now you need to add your developer account to Xcode. You can add your developer account by selecting Preferences… from the Xcode menu and opening the Accounts tab.
Click the plus button in the bottom left and choose Add Apple ID… from the list of options. Enter your credentials and click Add.
By adding your developer account to Xcode, it can communicate with the developer portal on your behalf. This makes some tasks a lot easier.