Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PhoneGap By Example

You're reading from   PhoneGap By Example Use PhoneGap to apply web development skills and learn variety of cross-platform mobile applications

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785285318
Length 368 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing and Configuring PhoneGap FREE CHAPTER 2. Setting Up a Project Structure with Sencha Touch 3. Easy Work with Device – Your First PhoneGap Application "Travelly" 4. Integrating the Travelly Application with Custom Service 5. Crazy Bubbles - Your First HTML5 Mobile Game 6. Share Your Crazy Bubbles Game Result on Social Networks 7. Building a Real-time Communication Application – Pumpidu 8. Building "Imaginary" – An Application with Instagram-like Image Filters 9. Testing the PhoneGap Application 10. Releasing and Maintaining the Application Index

Running the application on an iOS device

To run the application on an iOS device, you must perform the following steps:

  1. Join the Apple iOS Developer Program.
  2. Create a Provisioning Profile within the iOS Provisioning Portal.
  3. Verify that the Code Signing section's Code Signing Identity within the project settings is set to our provisioning profile name.

Let's assume that we already have a subscription to the iOS Developer Program. Now, you need to create an iOS Development Certificate and Provisioning Profile.

Go to https://developer.apple.com, then go to the "Member Center" link, and enter your Apple ID and password. After that, go to Developer Program Resources and select Certificates, Identifiers & Profiles. The following screen will appear:

Running the application on an iOS device

Generating the iOS developer certificate

Under the Certificates section, press the + button in order to start certificate generation. On the screen, select iOS App Development.

Then, press the Continue button. After that, we see the instructions for how to generate Certificate Signing Request (CSR) on our computer. At this stage, we can begin to generate the CSR on our computer. In the Applications folder on your Mac, open the Utilities folder and launch Keychain Access. Within the Keychain Access drop-down menu, go to Keychain Access | Certificate Assistant | Request a Certificate from a Certificate Authority. After that, we will see the following screen:

Generating the iOS developer certificate

In the User Email Address field, I entered my current e-mail. Usually, this is the same e-mail to access the Apple Developer Portal. In the Common Name field, I usually enter my name. If you have a company, it might be the company name. I am the owner of an Apple Developer account, so I do not need to send a request by e-mail. I just clicked on Save to disk and then on the Continue button. I saved the CSR file on your computer and completed the process of generating the Certificate Signing request.

Now, go back to the browser with instructions for the generation of CSR and click on Continue. I selected the .certSigningRequest file saved on my Mac and clicked on the Generate button. Once the certificate generation is over, I downloaded a ready certificate on my computer and double-clicked on it to add to my Mac keychain.

At this stage, the generation of the certificate is completed. Now, you need to attach your project team. The Xcode project needs to be assigned to a team so that Xcode knows where to create your code signing and provisioning assets.

To assign the Xcode project to a team, follow these steps:

  1. In the project navigator, view the Identity settings.
  2. If necessary, select the target, click on General, and click on the disclosure triangle next to Identity to reveal the settings.
  3. Choose your team from the Team pop-up menu.
    Generating the iOS developer certificate

This message appears because we have not generated a Provisioning Profile yet.

Adding the application identifier

In order to generate a Provisioning Profile for our application, it must be registered with the Apple Developer Portal. To do this, on the presented Xcode screen, copy Bundle Identifier to the clipboard and switch to Apple Developer Portal. In the Identifiers section, press the + button. On the next page, you must enter the application Name and paste Bundle ID from the clipboard, as presented in the following screenshot:

Adding the application identifier

After that, click on the Continue button, and on the next page, check the entered data and click on Submit. We added our application. Now, we need to register the device where we will be able to run our application.

Registering the device

To register the device in the Apple Developer Portal, go to Devices and click on the + button. On the form, you must enter the name of the device and its unique device identifier (UDID).

Registering the device

UDID can be found by connecting the Apple device to your computer in iTunes. If you go to the Device Manager tab and then to Summary, you will see the following screen:

Registering the device

Here, in the main section, you can copy the UDID by right-clicking on the UDID value. After that, go to the Apple Developer Portal, insert UDID, enter the Name of your device, and click on the Continue button:

Registering the device

Once the operation is complete, we will see our device in the Devices section. The next step is Provisioning Profile generation.

Generating a provisioning profile

To generate a Provisioning Profile for our application, go to the Provisioning Profiles | Development and press the + button. After that, select the iOS Development application type and click on Continue.

Generating a provisioning profile

In the next step, we will choose our application, Travelly, and go to the next page. Select the certificate generated by us and move on to the next step. In this step, we will select the devices on which we want to run our application:

Generating a provisioning profile

At this stage, I chose two devices. I want to be able to test our application on both devices.

Finally, go to the next page and enter a name of the Provisioning Profile. Let's enter Travelly. Complete the generation by pressing the Generate button. Then, we can download this Provisioning Profile, or allow Xcode to it.

Now, in Xcode, we need to select a proper Provisioning Profile. Follow these steps:

  1. In the project navigator, view the Identity settings.
  2. If necessary, select the target, click on Build Settings, and click on the disclosure triangle next to Code Signing to reveal the settings.
  3. Select Travelly as Provisioning Profile.
Generating a provisioning profile

Alternatively, you can simply click on a provisioning profile, and it will be automatically installed in the Xcode.

That's all. Now, you can run the application on the device. Connect your device to your computer using the USB cable. Select the intended device from the toolbar's scheme menu; in my case, it is Cybind's iPhone. Press the Run button that appears in the same toolbar to the left of the scheme. This button builds, deploys, and runs the application in the device. We can see how the application started on our device.

Similarly, we can run the application on our device from the console:

$ cordova run ios

This command displays a lot of information because the Cordova CLI builds iOS projects using Xcode, which displays all the information about how it builds the application.

Congratulations! We have successfully executed our initial application on the real iOS device.

You have been reading a chapter from
PhoneGap By Example
Published in: Aug 2015
Publisher:
ISBN-13: 9781785285318
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime