Testing Apps on iOS 8 Devices with Xcode 6

From Techotopia
Jump to: navigation, search
PreviousTable of ContentsNext
A Guided Tour of Xcode 6An Introduction to Swift Playgrounds


Learn SwiftUI and take your iOS Development to the Next Level
SwiftUI Essentials – iOS 16 Edition book is now available in Print ($39.99) and eBook ($29.99) editions. Learn more...

Buy Print Preview Book


In the chapter entitled A Guided Tour of Xcode 6 we were able to run an application in the iOS Simulator environment bundled with the iOS 8 SDK. Whilst this is fine for most cases, in practice there are a number of areas that cannot be comprehensively tested in the simulator. For example, no matter how hard you shake your computer (not something we actually recommend) or where in the world you move it to, neither the accelerometer nor GPS features will provide real world results within the simulator (though the simulator does have the option to perform a basic virtual shake gesture and to simulate location data). If we really want to test an iOS application thoroughly in the real world, therefore, we need to install the app onto a physical iOS device.

Many new features have been added to Xcode 6 to make the task of the developer easier. One of these features makes it considerably easier to obtain the signing certificates and provisioning profiles that are necessary to perform testing of applications on physical iOS devices.

A previous edition of this book, which was based on Xcode 4, dedicated no less than 11 pages to the process of obtaining a developer certificate, App ID and provisioning profile to test an application on a physical iOS device. Much of this work is now performed automatically by Xcode resulting in a much simpler path to testing applications on iOS devices.


Contents


Configuring Xcode with Apple IDs

The first step in setting up a fully configured development environment involves entering the Apple ID associated with your Apple Developer Program membership.

To enter this information, start Xcode and select the Xcode -> Preferences… menu option. From within the preferences window, select the Accounts tab as illustrated in Figure 5-1:


The Xcode 6 account preferences panel

Figure 5-1


To add an Apple ID, click on the + button in the lower left hand corner and select Add Apple ID… from the drop down menu. When prompted to do so (Figure 5 2), either enter the Apple ID and password associated with your Apple Developer Program membership, or click on the Join a Program… button if you are not yet a member.


Entering an Apple ID into Xcode 6

Figure 5-2


Repeat these steps to add additional Apple IDs if you are associated with more than one development team. Once the information has been entered, the accounts will be listed in the preferences window.

Generating Signing Identities

Before an application can be run on a physical iOS device for testing purposes it must first be signed with a developer signing identity. When the application is finished and ready to be placed on sale in the App Store it must then be signed with a distribution signing identity. Signing identities are comprised of a certificate and a private key.

Signing identities can be generated from within the Xcode account preferences panel. Begin by selecting the Apple ID for which the identities are to be generated before clicking on the View Details… button located in the lower right hand corner of the window. This will display a list of signing identities and any provisioning profiles associated with those identities. If no valid signing identities are listed (as is the case in Figure 5-3), the next step is to generate them.


Viewing Signing Identities in Xcode 6 - none configured

Figure 5-3


Begin by clicking on the + button and selecting the iOS Development option from the resulting menu. Xcode will then contact the Apple Developer Member Center portal and request and download a developer signing identity. Repeat these steps, this time selecting iOS Distribution from the menu to create and download a distribution signing identity. Once completed, the two identities should now be listed as shown in Figure 5-4:


Viewing Signing Identities in Xcode 6

Figure 5-4


Once created, signing identities and account information can be migrated to other development computer systems by clicking on the button displaying a gear cog on the first account settings page and selecting the Export Accounts… menu option. On the destination system repeat these steps, this time selecting the Import Accounts… option.

It is worth noting that the certificates associated with the signing identities can also be viewed and created within the Apple Developer Member Center portal. Within a browser, navigate to the following URL and log in using your Apple ID credentials:

https://developer.apple.com/membercenter

Within the member center, click on the Certificates, Identifiers and Profiles option and choose Certificates from the list of options under the iOS Apps category. On the resulting page, the certificates for both signing identifiers should be listed. Clicking on a certificate will display details such as the expiration date as outlined in Figure 5-5:


Viewing certificates in the Apple Developer Member Center

Figure 5-5


As can be seen in the left hand panel of Figure 5-5, the member center also provides options to manually create App IDs and Provisioning Profiles. With Xcode 6, however, these are typically created automatically.


Device Registration

Having generated signing identities the next step is to register a device for testing purposes. With the introduction of Xcode 6, device registration takes place automatically when an iPhone or iPad device is connected to the development system. Simply run Xcode, attach the device to the computer and wait for it to appear as an option on the run destinations menu. Figure 5 6, for example, shows two physical devices available for testing together with the standard iOS Simulator options:


Physical devices listed in the Xcode 6 run destinations menu

Figure 5-6


Details of the devices connected to the system can be obtained via the Xcode Devices window (Window -> Devices) as shown in Figure 5-7:


The Xcode 6 Devices window

Figure 5-7


To exclude a connected device from the list of potential targets on the device scheme menu, select the device from the Devices screen and use the settings menu in the bottom left hand corner of the window to deselect the Show in Run Destinations Menu option:


Excluding a device from the Xcode 6 run destinations menu

Figure 5-8

Learn SwiftUI and take your iOS Development to the Next Level
SwiftUI Essentials – iOS 16 Edition book is now available in Print ($39.99) and eBook ($29.99) editions. Learn more...

Buy Print Preview Book

Manually Adding Test Devices

In addition to allowing Xcode to automatically register connected devices for testing purposes, it is also possible to manually enter devices from within the Developer Portal. This is a useful option when the device is not currently available to be attached to the development system for registration (perhaps it belongs to a co-worker who has volunteered to perform some app testing).

To manually register a device, the UDID of that device is required. This can be obtained from the Xcode Devices window or from within iTunes when the device is attached. To find the UDID from within iTunes, connect the device, select it in iTunes and display the Summary screen. By default the summary screen will display the device serial number. Clicking on this number will cycle through a number of different values, eventually listing the UDID:


Getting a device UDID from within iTunes

Figure 5-9


Once the UDID of the device has been obtained, log into the Apple Developer Member Center portal, select the Certificates, Identifiers & Profiles option and on the resulting page choose the Devices option listed under iOS Apps. On the iOS Devices screen, click on the + button to add a new device and enter a name for the device and the UDID into the Register Device section:


Registering an iOS device in the Apple Member Center

Figure 5-10


Running an Application on a Registered Device

With a registered device connected to the development system, and an application ready for testing, refer to the device menu located in the Xcode toolbar. There is a reasonable chance that this will have defaulted to one of the iOS Simulator configurations (in the case of Figure 5-11, this is the iPhone 6 simulator).


The Xcode device toolbar menu with a simulator selected

Figure 5-11


Switch to the physical device by selecting this menu and changing it to the device name as shown in Figure 5-12:


Choosing a target iOS device in Xcode 6

Figure 5-12


Xcode will request a provisioning profile that matches the App ID of the application and includes permission to run on the specified device, build the application using the developer signing identity before installing the application and provisioning profile on the device. Finally the application will be launched on the device.

Summary

Without question, the iOS Simulator included with the iOS 8 SDK is an invaluable tool for testing applications during the development process. There are, however, a number of situations where it is necessary to test an application on a physical iOS device. In this chapter we have covered the steps involved in provisioning applications for installation and testing on iPhone and iPad devices.


Learn SwiftUI and take your iOS Development to the Next Level
SwiftUI Essentials – iOS 16 Edition book is now available in Print ($39.99) and eBook ($29.99) editions. Learn more...

Buy Print Preview Book



PreviousTable of ContentsNext
A Guided Tour of Xcode 6An Introduction to Swift Playgrounds