In this chapter, we will cover:
Joining the iOS Developer Program
Accessing the iOS Provisioning Portal
Generating a Certificate Signing Request using Windows
Generating a Certificate Signing Request using Mac OS X
Obtaining your development certificate
Creating a P12 certificate using Windows
Creating a P12 certificate using Mac OS X
Registering a device
Creating an App ID
Creating a development provisioning profile
Installing a provisioning profile on your device
When writing iOS applications, the creation and management of certain files is necessary in order to test on a real device. The exact files required depends on whether you are currently developing or preparing for distribution. We will focus primarily on development.
By the end of this chapter, you will have created a P12 certificate file and a development provisioning profile, both of which are required if you want to make full use of the recipes throughout this book. Along the way, you will learn the ins and outs of various tools including Apple's iOS Provisioning Portal, which you will come to use extensively during your time as an iOS developer.
Don't worry if it doesn't all make perfect sense at first. If you follow the steps detailed in each recipe, you will end up with the development files required to work through the rest of the book.
Registering as an Apple developer and enrolling in one of the iOS Developer Programs are prerequisites for anyone wishing to write iOS apps.
Although you can enroll in a free program, if you want to install your applications on devices and distribute them in the App Store, you will need to pay a $99 annual fee to join the standard program.
Those developing with the iOS SDK can select the free program and test their apps using the iOS simulator, which is provided with Apple's official development tools. Unfortunately, native iOS apps built with Flash Professional do not run on the simulator. Therefore, if you want to fully test the examples provided in this book, you will need to install them on an iOS device.
Note
Within Flash Professional, you can use the AIR Debug Launcher (ADL) to test your applications on the desktop; however, no iOS device capabilities are supported thus restricting ADL's usefulness.
Let us take a look at the steps required to enroll.
Enrollment takes place on the Apple Developer website. If you aren't using Apple's Safari browser, then it is recommended that you download and install it, as problems are reported from time to time when trying to use certain areas of the site on other browsers.
Safari is the default web browser preinstalled on Mac OS X. Those using Windows, who don't already have Safari, can download it from www.apple.com/safari/download.
If you already have Safari installed, then make sure that you have the most recent version.
Tip
There are several paths you can take during the enrollment process and once you have completed it, it may not be possible to change some of your choices. Think carefully before submitting your enrollment details and purchasing your Developer Program. You may want to first read through this recipe in its entirety to ensure that you are fully aware of all the options available to you.
Visit the Apple developer website at http://developer.apple.com. Scroll down the page until you see the Join the iOS Developer Program link as shown in the following screenshot:
Click on the link. You will be taken to the iOS Developer Program page where you will find an Enroll Now button at the top of the page.
Click on the Enroll Now button to move to the Enroll in the Apple Developer Programs page. The three main steps required for enrollment are listed on this page. They are:
Register as an Apple Developer
Select Your Programs
Complete Your Purchase
At the bottom of the page is a Continue button, which will begin the process of taking you through each of these steps. Go ahead and click on it.
From the Are you new or a registered Apple developer? page, you will be able to register as a new Apple developer. Within the New Apple Developer column, click on the I need to create a new account and Apple ID for an Apple Developer Program radio button as shown in the following screenshot:
Click on the Continue button to move to the Are you Enrolling as an Individual or Company? page.
Two options are provided. Enroll as an individual or enroll on behalf of a company.
Depending on your needs, click on either the Individual or the Company button at the bottom of the page.
Now complete your personal profile by performing the following tasks:
Specify a desired Apple ID and password.
Set up some security information that can be used to verify your identity.
Submit your personal information.
Note
When submitting your contact information, the name you specify will appear as the "seller" for any apps you distribute on the App Store.
Do not attempt to add an alias or organization name within the name fields. This will most likely result in failure of your Apple Developer registration or suspension of your account when the error is eventually noticed by Apple.
If you want to have a company name to appear as the "seller", then enroll as a company and provide Apple with the relevant legal documentation to verify your identity.
If you are registering as an individual, then enter your first and last name into the Company/Organization field.
Read the information provided on the displayed page carefully and once you have completed the form, click on the Continue button which will take you to the Complete your professional profile page.
For the Which Apple platforms do you develop with? field, check on the iOS checkbox. This will reveal a list of additional fields that must be populated.
When you come to the Please select the primary category for your application(s) field, ensure that you click on the Commercial Applications radio button.
Note
By selecting to develop commercial applications, you will have to provide your banking details before you can distribute your apps; however, you won't be asked for this information as part of the enrollment process. If you plan only to distribute free apps, then you can select the Free Applications radio button and no banking details will be required. This option will suffice for the examples within this book; however, if you plan to sell apps at some point, then stick with the Commercial Applications option.
Once you have provided answers for all the fields in the form, click on the Continue button at the bottom of the page.
Carefully read the Registered Apple Developer Agreement that is displayed. Acknowledge that you have read it by checking on the checkbox and then clicking on the I Agree button at the bottom of the page.
A verification code will be sent to your e-mail address. Retrieve the code and enter it into the text field provided on the Enter the verification code sent to your email page. Click on Continue.
A second e-mail will be sent confirming that you are now a registered Apple developer.
Within your web browser you will be taken to the Enter your billing information for identity verification page.
Enter your first and last name exactly as they appear on your credit card. Also provide your credit card billing address.
Click on the Continue button at the bottom of the page.
The Select Your Program page will appear. As shown in the following screenshot, check on the iOS Developer Program checkbox and click on Continue at the bottom of the page:
The next page will let you review your enrollment information. Verify that you have selected the iOS Developer Program and that your personal details and billing information are correct. If any of the information is incorrect, click on the Go Back button at the bottom of the page and make any necessary alterations.
Click on Continue to submit your enrollment information to Apple.
The Program License Agreement page will appear. Acknowledge that you have read it by checking on the checkbox, then click on the I Agree button at the bottom of the page.
A purchase page will appear. Click on Add to cart to proceed to your country's online store in order to purchase your program.
A new browser window will open and you will be taken to the Apple Store. Confirm that your iOS Developer Program is in your basket and click on the Checkout Now button on the right side of the page to purchase the item.
An activation e-mail will be sent to you within 24 hours. When you receive it, follow the instructions to activate your iOS Developer Program.
Registering as an Apple developer and activating your Developer Program enables you to access the iOS Provisioning Portal through Apple's iOS Dev Center website. The iOS Provisioning Portal takes you through the necessary steps to test and distribute your apps on iOS devices, and will be used throughout this chapter.
You will use the Apple ID and password that you set up to log into the iOS Dev Center at http://developer.apple.com/devcenter/ios.
The following additional pieces of information are worth considering.
If you opt to enroll as a company, then you can add additional team members to your account who can access iOS Developer Program resources. This will allow, for example, other team members to generate and download the developer files required to build and deploy apps to an iOS device.
If you enroll as an individual, then you will be the sole developer who has access to the program resources. It will be your responsibility to generate all required developer files and manage the list of test devices.
The iOS Dev Center contains a wealth of resources. While the documentation and tools available are aimed at developers using the iOS SDK, you will find some that will be of use when building your own apps with Flash Professional.
An important document to start with is the iOS Human Interface Guidelines at http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG. It describes the guidelines and principles that help you create apps that feel as though they were designed specifically for iOS.
Also, if you are planning to release your apps on the App Store, then read the App Store Review Guidelines at http://developer.apple.com/appstore/guidelines.html.
If you are developing on Mac OS X you may also want to download the developer toolset. While this book will not cover Apple's developer tools, spend some time exploring the Instruments application, which comes as part of the bundle, and provides powerful profiling and debugging features that can help you fine tune your apps.
A good place to start is the Introduction to Instruments User Guide at http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction.
The iOS Provisioning Portal is an online tool designed to take you through the steps required to test your apps on iOS devices and prepare them for distribution on the App Store.
This is where you will create and download the developer files that are required to build your apps with Flash Professional.
Let us go through the steps required to access it.
You will need an Apple ID to enroll on the iOS Developer Program.
If you haven't already done so, follow the steps detailed in the Joining the iOS Developer Program recipe.
Visit the iOS Dev Center website at http://developer.apple.com/devcenter/ios. Click on the Log in button at the top of the page.
On the Sign in with your Apple ID page, enter your Apple ID and password into the text fields. Click on the Sign in button.
If successful, you will be taken back to the iOS Dev Center home page where you will now have access to the main areas of your Developer Program including the iOS Provisioning Portal. Links to these can be found near the top-right of the home page underneath the iOS Developer Program heading.
Click on the iOS Provisioning Portal link to access the portal's home page, which is shown in the following screenshot:

The Provisioning Portal provides you with the resources to develop and distribute your iOS apps.
For the examples in this book, you only need to concern yourself with development. The following are the four main steps required to do this:
Obtain a development certificate
Register iOS devices for testing
Create unique IDs for your apps
Create and download development provisioning profiles
These steps can be performed from the links on the left-hand side of the Provisioning Portal page and are broken down and covered throughout the remainder of this chapter.
Alternatively, Apple has provided the Development Provisioning Assistant, which can be used to guide you through the process. However, the Provisioning Assistant is not covered in this book.
You are encouraged to spend time exploring the Provisioning Portal as it is integral to the iOS development process.
The following information may also be of some use.
On the right-hand side of the portal's home page is the Resources section where you can find links to guides, "how to" videos, documentation, and user forums.
The "how to" videos are ideal if you need further clarification regarding the provisioning steps. At the head of the Resources section you will also find a link to the Program User Guide, which covers the provisioning process in detail.
Remember that all content on the site will be aimed at Mac OS X owners. If you are using Windows, then some of the content may not be applicable.
If you enrolled on behalf of a company, then you will also be able to add other team members to your account.
As the original enrollee, you have access to all iOS Provisioning Portal capabilities and can assign roles for any members you invite. The role you assign to an individual determines the privileges they get and dictates the tasks they can undertake.
Team management is handled within the Member Center, which you can access from the Provisioning Portal's home page. Simply click on the Visit the Member Center now link on the center of the portal's home page.
Those who have signed-up as an individual will not be able to add team members but will have access to all Provisioning Portal capabilities.
For a comprehensive guide to team administration, take a look at the Program User Guide within the Resources section.
The steps required for preparing your apps for App Store submission and distribution are not covered within this book. However, once you are comfortable with the provisioning process for application development, you will find that distribution isn't too dissimilar.
Comprehensive documentation regarding distribution is available from the Program User Guide in the Provisioning Portal's Resources section.
As a member of the iOS Developer Program, you are entitled to support from the Apple Developer Technical Support team, where you can receive direct one-to-one help from a qualified Apple engineer.
Included with your Developer Program membership is free technical support for two incidents during your membership period.
However, you should be aware that this support is primarily for developers using the iOS SDK. Apple engineers will not be able to help with questions regarding Flash Professional.
A Development Certificate is used to identify a developer for the purpose of installing and testing apps on iOS devices. Without one you can't publish native iOS apps from Flash Professional. You obtain a development certificate from Apple's iOS Provisioning Portal but to do that you must first generate a Certificate Signing Request (CSR) file.
The process for generating a CSR differs depending on your choice of operating system.
The steps for Microsoft Windows are covered here. If you are using Mac OS X, then refer to the Generating a Certificate Signing Request using Mac OS X recipe.
CSR files are generated using OpenSSL, which can be downloaded and installed from www.slproweb.com/products/Win32OpenSSL.html. You will actually need to install two files from the site.
First scroll down to the Download Win32 OpenSSL section and download the Visual C++ 2008 Redistributables installer. Simply run the executable and follow the wizard through the installation process.
Next, download and run the Win32 OpenSSL v1.0.0e Light installer. The wizard will ask you to select where OpenSSL should be installed. Keep the default location set to
C:\OpenSSL-Win32
. Additionally, when prompted, instruct the installer to copy OpenSSL's DLLs to The Windows system directory.
Open a command prompt window using administrator privileges.
Note
How you run a command session with administrator privileges depends on your choice of operating system.
If you are a Windows 7 or Vista user, then click on the Start button and type
cmd
into the search box. However, rather than simply pressing Enter, you should press Ctrl + Shift + Enter. A dialog will appear asking if you want to allow the program to make changes to your computer. Click on the Yes button.If you are using Windows XP, then ensure you are logged on with an administrator account. Click on the Windows Start button and then select Run. From the Run dialog box, type
cmd
and press Enter.From the command prompt move to OpenSSL's
bin
folder by entering the following command:cd C:\OpenSSL-Win32\bin
Now create a private key by entering:
set RANDFILE=.rnd
followed by:
openssl genrsa -out mykey.key 2048
The file,
mykey.key
, will be output to OpenSSL'sbin
folder.Using your private key you can now create the CSR file. To do this, a command with the following format is required:
openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=yourAddress@example.com, CN=John Doe, C=US"
You will need to make some changes when typing the preceding command into the command line. Replace the e-mail address and certificate name with the same e-mail address and name you enrolled within the iOS Developer Program. Also, if you live outside the United States, you will need to edit the country code.
Note
A list of country codes that can be used when creating a CSR can be found on the DigiCert website at www.digicert.com/ssl-certificate-country-codes.htm.
A CSR file named,
CertificateSigningRequest.certSigningRequest
will be created and output to thebin
folder.
You now have a CSR file that contains your personal information (your name, e-mail address, and country) and will be used to request a development certificate from Apple.
When the CSR file was created, OpenSSL also created a public and private key. The public key is included within the CSR file while the private key is used to sign the request.
Don't delete your CSR file or the private key as they will both be required later in this chapter.
A development certificate is used to identify a developer for the purpose of installing and testing apps on iOS devices. Without one you can't publish native iOS apps from Flash Professional. You obtain a development certificate from Apple's iOS Provisioning Portal but to do that you must first generate a Certificate Signing Request (CSR) file.
The process for generating a CSR differs depending on your choice of operating system.
The steps for Mac OS X are covered here. If you are using Microsoft Windows then refer to the Generating a Certificate Signing Request using Windows recipe.
Follow the steps to generate a CSR:
Launch the Keychain Access application from the
Applications/Utilities
folder.Once opened, select Preferences from the Keychain Access (Cmd + ,) menu.
From the Preferences dialog box, click on the Certificates tab and ensure that both Online Certificate Status Protocol (OCSP) and Certificate Revocation List (CRL) are set to Off. Close the dialog box.
On the Keychain Access menu select Certificate Assistant | Request a Certificate from a Certificate Authority.
The Certificate Assistant dialog box will appear where you can enter your personal information. In the text fields provided, enter the e-mail address and name you enrolled within the iOS Developer Program. Leave the CA Email Address field blank and click on the Save to disk radio button. Now click on Continue.
When asked, select to save the certificate to your desktop.
A CSR file named CertificateSigningRequest.certSigningRequest
will be created and saved on disk.
You now have a CSR file that contains your personal information (your name and e-mail address) and will be used to request a development certificate from Apple.
When the CSR file was created, the Keychain Access application also created a public and private key. The public key is included within the CSR file while the private key is used to sign the request. Using Keychain Access you can see both keys listed within the Keys category.
Don't delete your CSR file or the private key as they both will be required later in this chapter.
Now that you have a Certificate Signing Request (CSR), you can use it to obtain a development certificate from Apple. This is done by uploading your CSR file to the iOS Provisioning Portal and waiting for approval.
If you haven't already done so, generate a CSR file. Depending on your choice of operating system, see either the Generating a Certificate Signing Request using Windows recipe or the Generating a Certificate Signing Request using Mac OS X recipe for more details.
Log into the iOS Dev Center at http://developer.apple.com/devcenter/ios and make your way to the Provisioning Portal.
Click on the Certificates link on the left-hand side of the portal's home page to move to the certificates section. As shown in the following screenshot, ensure that the Development tab is selected:
Now, click on the Request Certificate button on the far-right of the screen, which will take you to the Create iOS Development Certificate page.
At the bottom of the page is a Browse button. Scroll down a little further and to the far-right you will also see a Submit button.
First, click on Browse and navigate to the CSR file on your hard drive.
Once you have selected your CSR file, click on Submit.
You will be taken back to the Certificates section where a certificate will now be listed. Its status will initially be set to Pending Issuance and an e-mail will be sent to you from Apple with the subject heading Certificate Request Requires Your Approval.
This e-mail is intended for those working in a team environment. If you are registered as an individual then you don't need to take any further action. Simply refresh the page in your browser and the certificate's status will automatically change to Issued.
Click on the Download button underneath the Action column and save the development certificate to your hard drive.
Where you save the certificate depends on your choice of operating system. If you are on Windows, then save it to OpenSSL's
bin
folder atC:\OpenSSL-Win32\bin\developer_identity.cer
. If you are using Mac OS X, then simply save thedeveloper_identity.cer
file to your desktop for the time being.
A development certificate is restricted to app development only and is valid for a limited period. Take a look at the Expiration Date column from the Provisioning Portal's Certificates section to see when your digital certificate will expire. Typically certificates are valid for a year.
Once a certificate expires, you will need to revoke it and request a new one from the Provisioning Portal.
You are now one step closer to being able to compile iOS apps directly from Flash Professional. However, before Flash can digitally sign any of the iOS apps you create, your development certificate will have to be converted to a P12 certificate file, which we will cover in the next recipe.
Let us cover some additional detail, some of which is particularly important for those who enrolled on behalf of a company and are working in a team.
All team members can make iOS development certificate requests. As the original enrollee, it will be your responsibility to approve or reject those requests.
When a team member requests a development certificate, you will receive an e-mail with the subject heading Certificate Request Requires Approval. This is identical to the e-mail sent to those registered as an individual; however, when working in a team environment, you will need to take action by clicking on the link provided within the e-mail.
The link will open in your default web browser and take you to the Provisioning Portal where you can log in and view any certificate request awaiting approval. On the Certificates page, simply find the certificate request that is waiting for approval and click on either Accept or Reject from the Actions column.
For additional details, refer to the Program User Guide, which can be found within the Provisioning Portal's Resources section.
As stated, the original enrollee has the authority and responsibility to either approve or reject development certificate requests. The original enrollee has access to all Provisioning Portal capabilities and is designated as the Team Agent.
The Team Agent can invite others and assign them the role of either a Team Admin or a Team Member.
Team Admins can themselves invite new Team Admins and Team Members. In addition, they can approve or reject certificate signing requests.
A Team Member has the lowest privileges and must have any certificate signing requests approved by either the Team Agent or Team Admin.
Importantly, all three types of members can test apps on iOS devices.
From now on, the original enrollee within a team environment will be referred to as the Team Agent throughout this book.
For a thorough explanation of working within a team environment including a full list of member responsibilities, refer to the Program User Guide within the Provisioning Portal's Resources section.
In order to distribute your app on the App Store, you will need to request a distribution certificate. Although the steps aren't covered in this book, they are similar to those carried out to obtain and work with a development certificate.
For further information, refer to the Distribution section of the Program User Guide, which can be found within the Provisioning Portal's Resources section.
Now that you have downloaded your development certificate from the Provisioning Portal, the final step is to convert it to a P12 certificate file.
Flash Professional will use this P12 file to digitally sign any iOS apps you create.
The process for generating a P12 certificate file differs depending on your choice of operating system.
The steps for Microsoft Windows are covered in this recipe. If you are using Mac OS X, then refer to the Creating a P12 certificate using Mac OS X recipe.
You will need the development certificate that you created and downloaded from the iOS Provisioning Portal. If you haven't already done this, then follow the steps outlined in the Obtaining your development certificate recipe.
As was the case when creating a CSR, you will need to use OpenSSL to convert your development certificate into a P12 file by executing the following steps:
Open a command session in Windows as the administrator.
Move to OpenSSL's
bin
folder by entering the following command into the command prompt:cd C:\OpenSSL-Win32\bin
The first step is to convert your development certificate file into a PEM certificate file by entering the following command line statement:
openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM
For this to work you will need to save the
developer_identity.cer
file, that you downloaded from the Provisioning Portal to OpenSSL'sbin
folder.Now using the PEM file and your private key, generate a valid P12 file by entering:
set RANDFILE=.rnd
followed by:
openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out ios_dev.p12
During this process, OpenSSL will ask you to specify an export password. Flash Professional will prompt you for this password while compiling your
.swf
files into native iOS apps, so choose something you aren't likely to forget. Enter your password and confirm it when OpenSSL asks you to verify it.If successful, an
ios_dev.p12
file will be created in thebin
folder. It is important that you keep this file safe as you will need it to publish any of the examples in this book.Using Windows Explorer, navigate to your
Documents
folder and create the following folder structure within it:packt\flash-ios-cookbook\developer-files\
. This is where we will keep our P12 certificate file from now on.Copy
ios_dev.p12
fromC:\OpenSSL-Win32\bin\
to thedeveloper-files
folder you just created.
When publishing iOS apps from Flash Professional, you will be prompted for your P12 certificate file and password. Both are used to digitally sign your app allowing it to be deployed and tested on an iOS device.
The P12 certificate is the first of the two files that will be used by Flash Professional every time you make an iOS build.
Finally, a few additional words regarding certificates.
When your developer certificate eventually expires, you will need to request a new one from the Provisioning Portal before converting it to a P12 file. Any apps that were published using the old certificate will no longer run on your iOS device and will need to be republished using a new valid P12 file.
If you accidentally delete your existing P12 file, then you can simply recreate it from the steps outlined in this recipe. There is no need to request a new development certificate from the Provisioning Portal.
Now that you have downloaded your development certificate from the Provisioning Portal, the final step is to convert it to a P12 certificate file.
Flash Professional will use this P12 file to digitally sign any iOS apps you create.
The process for generating a P12 certificate file differs depending on your choice of operating system.
The steps for Mac OS X are covered here. If you are using Microsoft Windows, then refer to the Creating a P12 certificate using Windows recipe.
You will need the development certificate that you created and downloaded from the iOS Provisioning Portal. If you haven't already done this, then follow the steps outlined in the Obtaining your development certificate recipe.
Execute the following steps:
Launch the Keychain Access application from the
Applications/Utilities
folder.Select File | Import Items (Shift + Cmd + I) from the drop-down menu. From the file browser, select your certificate from
Desktop/developer_identity.cer
.Your certificate will be installed in the Keychain Access application. You can confirm this by clicking on the Certificates category where you will see your iPhone Developer certificate listed.
Now, select the Keys category and find the private key associated with your certificate. Both your public and private keys will be listed and named using the name you entered when creating your CSR. This is shown in the following screenshot:
Context-click on the private key and select Export. A dialog box will appear asking you to specify where to save the P12 file when it is created. Choose the desktop and click on Save.
Keychain Access will ask you to specify an export password. Flash Professional will prompt you for this password while compiling your
.swf
files into native iOS apps, so choose something you aren't likely to forget. Enter your password and confirm it by re-entering it into the Verify field and then click on OK.Note
You may also be prompted by Keychain Access to enter your Mac's login password. If so, do this and click on Allow to grant Keychain Access permission to export the key.
If successful, a P12 certificate file will be created and saved to your desktop.
It is important you keep this file safe as you will need it to publish any of the examples in this book.
Using Finder, navigate to your
Documents
folder and create the following folder structure within it:packt/flash-ios-cookbook/developer-files/
.Copy your P12 file to this new location. We will keep it here from now on.
When publishing iOS apps from Flash Professional, you will be prompted for your P12 certificate file and password. Both are used to digitally sign your app allowing it to be deployed and tested on an iOS device.
The P12 certificate is the first of two files that will be used by Flash Professional every time you make an iOS build.
Finally, a few additional words regarding certificate expiration.
When your developer certificate eventually expires you will need to request a new one from the Provisioning Portal before converting it to a P12 file. Any apps that were published using the old certificate will no longer run on your iOS device and will need to be republished using a new valid P12 file.
If you accidentally delete your existing P12 file, then you can simply recreate it from the steps outlined in this recipe. There is no need to request a new development certificate from the Provisioning Portal.
Any devices that you want to use for testing will have to be registered. Every iOS device has a Unique Device Identifier (UDID) that needs to be entered into the Provisioning Portal as part of the registration process.
We will learn in this recipe how to locate a device's UDID and add it to the Provisioning Portal.
A device's UDID can be obtained using iTunes.
iTunes typically comes installed on Mac OS X. Those using Windows, who don't already have iTunes, can download it from www.apple.com/itunes/download.
If you already have iTunes installed, then make sure that you have the latest version.
Follow the steps to register your device:
Launch iTunes and connect your iOS device through USB. After a brief moment the device will appear within the DEVICES section in iTunes.
Click on the device's name to display a summary.
Here, you will find its 11-character serial number listed near the top of the screen. Click on the serial number to reveal the device's 40-character UDID, as you can see in the following screenshot. The UDID will replace the serial number that was shown in the following screenshot:
Take a copy of the UDID by selecting Edit | Copy (Ctrl + C or Cmd + C) from iTunes' drop-down menu.
Log into the iOS Dev Center at http://developer.apple.com/devcenter/ios and make your way to the Provisioning Portal.
Move to the Devices section by clicking on the link on the left-hand side of the Portal's home page. Ensure that the Manage tab is selected. From this page, you will be able to manage the devices you would like to test with your apps.
Click on the Add Devices button near the top-right corner of the page. You will be shown an Add Devices page where you can enter your device's UDID and also assign a name to it for identification purposes.
Add your device's UDID and enter a name for it. Once you are done, click on the Submit button near the bottom-right corner of the page. The page will refresh and as shown in the following screenshot, you will see your newly registered device listed on the screen:
If you have additional iOS devices that you would like to use for testing then go ahead and add them now.
Fundamentally, the provisioning process is there to allow you to test an app that you have written on a device that you own.
Registering devices on the Provisioning Portal is another step towards achieving that. If device registration wasn't required, then you could theoretically circumvent the App Store's distribution model by simply installing apps on an arbitrary number of devices.
Apple's restrictions are in place to not only guard its distribution model but to also protect your own development apps from falling into the wrong hands and being run on unauthorized devices.
Registering devices is a fairly trivial process. However, there are a few other options and scenarios you should be aware of.
When working in a team environment, only a Team Agent or Team Admin can add devices. Team Members do not have the required privileges to do this.
If you are unhappy with the identifier you assigned to a device, you can change it at a later date. Within the Provisioning Portal, simply move to the Devices section and find the device in the Current Registered Devices list. On the right-hand side within the Actions column, click on the Edit link for that device.
You can only add a maximum of 100 devices per year to your Developer Program. Any devices you add and then later remove will still count towards that total, so think carefully when managing your list.
If at the end of the year you renew your iOS Developer Program, you will be able to reset your devices list before adding any additional devices. However, once you begin adding devices again, any device you choose to remove will once again count against your device limit.
There is an app available from the App Store called UDID Sender that you may find useful. UDID Sender will extract your device's UDID and automatically populate it in an e-mail for you to send.
This can be particularly useful for large organizations where the Team Agent or Team Admin can expect a large number of device registration requests from Team Members.
To save the Team Admin from having to individually retrieve each device and discover its UDID from iTunes, they can simply rely on a Team Member e-mailing the device's ID directly to them.
UDID Sender can be downloaded from iTunes or the App Store and is free.
Every app you write must be assigned an App ID, which is a unique identifier used by iOS.
There are two types of App IDs: Explicit App IDs and Wildcard App IDs. To ease development, you can use a wildcard rather than an explicit App ID. This removes the need to generate an ID for every single app and will be particularly useful when it comes to working through and testing the examples within this book.
Let us create a wildcard App ID that can be used across multiple apps.
Execute the the following steps:
Log into the iOS Dev Center at http://developer.apple.com/devcenter/ios and make your way to the Provisioning Portal.
Move to the App IDs section by clicking on the link on the left-hand side of the Portal's home page. Ensure that the Manage tab is selected. From this page, you can add new App IDs and view any that you previously created.
On the far-right side of the page, across from the App IDs heading is the New App ID button. Click on it to be taken to the Create App ID page.
A common name should be assigned to every new App ID. This is used throughout the Provisioning Portal to identify that App ID. Enter General Development into the text field directly below the Description heading.
Now you can create the App ID. Enter
*
into the Bundle Identifier text field. Your Create App ID page should resemble the following screenshot:Click on the Submit button at the bottom-right of the page. You will be taken back to the App IDs page where you will see your newly created App ID listed in a table.
An App ID is a unique string used to identify an app (or multiple apps) from a developer or team.
It consists of two parts: a Bundle Seed ID and a Bundle Identifier. The Bundle Seed ID is a universally unique 10-character prefix generated by Apple. The Bundle Identifier is a unique suffix determined by yourself, which can include the wildcard symbol "*".
When compiling an iOS app from Flash Professional, you will need to choose an App ID you want associated with your app and provide it to Flash. Although you will be asked to submit the App ID as part of the publishing process, you actually only provide Flash with the Bundle Identifier portion of the App ID.
If your Bundle Identifier contains the wildcard character, then you will need to substitute the wildcard with an arbitrary string that will uniquely represent your app. If a wildcard has not been used, then you will have to specify the Bundle Identifier exactly as it was entered into the Provisioning Portal.
The benefit of a wildcard is that it allows you to create a single App ID that can be used with any application you develop. This will be particularly useful when working through this book as it removes the need to revisit the Provisioning Portal to create a unique App ID for each recipe.
The App ID you just created by following this recipe's steps is all that is required for working through the examples provided within this book. However, you may find the following additional details useful for your own personal projects.
Although we used a single asterisk to represent the Bundle Identifier, Apple's recommended practice is to use a reverse-domain name style.
You should be familiar with this naming convention as it is commonly used for naming packages in ActionScript and helps prevent namespace collisions; a domain name can only be owned by an individual or organization.
Take, for example, the domain name yeahbutisitflash.com
. Rather than using a single asterisk, an App ID can be created that will work across multiple apps by using the following Bundle Identifier: com.yeahbutisitflash.*
.
To use this App ID to publish multiple apps from Flash Professional, provide Flash with the full Bundle Identifier but replace the asterisk with a unique string of your choice for each of your apps.
For example, if you are working on two individual test apps, then you could specify to Flash that the first app's ID is com.yeahbutisitflash.test1
whereas the other's could be set to com.yeahbutisitflash.test2
.
Both apps are still using the com.yeahbutisitflash.*
ID registered in the Provisioning Portal, but the wildcard has been replaced in each with a unique string that distinguishes the apps from one another.
An app that is ready for distribution on the App Store cannot have a wildcard specified within its Bundle Identifier.
When you are ready to submit your app to the App Store, you will need to create a new App ID from the Provisioning Portal and publish your app from Flash Professional using the new ID.
For example, you may have been using the Bundle Identifier com.yeahbutisitflash.*
during the development of a camera app, but for distribution you will have to create a new App ID that has the wildcard removed and is guaranteed to be unique to that app. The following Bundle Identifier would suffice: com.yeahbutisitflash.camera
.
It is worth noting that during development you don't have to use the wildcard within your Bundle Identifiers either, but it is useful as it allows you to quickly deploy multiple test apps to your device. If you are using an App ID that doesn't contain a wildcard, then you will be unable to deploy separate apps to your device that uses that App ID, forcing you to register a new App ID within the Provisioning Portal for each app.
The Provisioning Portal does not allow you to delete or edit any of the App IDs that you have created. Take care while naming your App IDs and assigning their Bundle Identifiers as these details cannot be changed at a later date. There is no limit to the number of App IDs you can register, so if you do make a mistake you can create and add a new one later.
Once you have a development certificate and at least one registered iOS device and an App ID, you are ready to create a provisioning profile. A development provisioning profile is a file that ties an app (or group of apps) to one or more authorized developers and a set of devices. Before you can test an app on a device, you must first install a provisioning profile onto it. A device can have multiple provisioning profiles installed.
Provisioning profiles are created from the iOS Provisioning Portal.
This recipe will take you through the steps required to create a provisioning profile that will allow you to test this book's examples on a device.
In order to complete this recipe, you will need to create a development certificate, register an iOS device, and have an App ID. If you haven't already done this, then complete the following recipes first:
Obtaining your development certificate
Registering a device
Creating an App ID
Follow the steps to create a development provisioning profile:
Log into the iOS Dev Center at http://developer.apple.com/devcenter/ios and move to the Provisioning Portal.
Click on the Provisioning link on the left-hand side of the Portal's home page. You will be taken to the provisioning page and the Development tab will be selected.
Click on the New Profile button found at the far-right of the Development Provisioning Profiles heading. You will be taken to the Create iOS Development Provisioning Profile page.
From this page you will generate a provisioning profile by performing the following steps:
Assigning a name to the provisioning profile.
Associating a development certificate with it.
Selecting an App ID.
Selecting one or more iOS devices that can be used for testing.
First, enter Flash iOS Cookbook into the Profile Name text field. From the Certificates field, check on the checkbox next to your development certificate. From the App ID drop-down box, select the General Development App ID you created a while ago. Finally, check on the checkbox next to the device you would like to test this book's examples with. If you have registered more than one device, then you can select them all.
Click on the Submit button at the bottom-right of the page.
You will be taken back to the Development Provisioning Profiles page where your provisioning profile will be listed with a status of Pending assigned to it. Refreshing the page in your browser will change the provisioning profile's status to Active.
Now click on the Download button underneath the Actions column. Save the
Flash_iOS_Cookbook.mobileprovision
file to the same location as your P12 certificate file. For the exact path, refer to either the Creating a P12 certificate using Windows recipe or the Creating a P12 certificate using Mac OS X recipe.
Your development provisioning profile has been associated with the General Development
App ID from the Creating an App ID recipe. Being a wildcard App ID, this provisioning profile can be used to run and test any of this book's examples on an authorized device.
The provisioning profile needs to be installed on authorized devices and is also required by Flash Professional. In order to compile a native iOS app, you need to provide Flash with not only your P12 certificate file, but also the provisioning profile associated with the app you are attempting to compile.
Before we move to the final recipe, you may find the following additional information useful.
A development provisioning profile is restricted to app development and is valid for only three months. If your provisioning profile expires during development, then you will need to create a new one from the Provisioning Portal. Remember to install the new profile on any authorized devices and to rebuild your app from Flash using your new profile.
Unlike App IDs, a provisioning profile can be removed from the Provisioning Portal. From the list of provisioning profiles, simply check on the checkbox next to each one you would like to delete. And click on the Remove Selected button at the bottom of the list of profiles.
You can also edit an existing provisioning profile. On the right-hand side within the Actions column, click on the profile's Edit link. You can either modify the original details you associated with the profile or even make a duplicate copy of a profile before making changes to it.
There are in fact three types of provisioning profile that can be created. This book will focus on the use of the development provisioning profile but the provisioning process also covers two methods of distribution—Ad Hoc and App Store.
An Ad Hoc Distribution Provisioning Profile is used to share an app with up to 100 other iOS users for testing. An App Store Distribution Provisioning Profile on the other hand is used to build and submit an app to the App Store.
When creating either an Ad Hoc or App Store distribution provisioning profile, you will need to request and use a distribution certificate rather than the development certificate required by a development provisioning profile.
For more details, refer to the Distribution section of the Program User Guide, which can be found within the Provisioning Portal's Resources section.
If you are working in a team environment, you must be either the Team Agent or a Team Admin to create a provisioning profile. When creating a provisioning profile, check on the checkbox next to the certificate of each team member who is to be granted permission to build and test the app(s) associated with the provisioning profile's App ID.
Now that you have a provisioning profile you need to install it onto a device. This will allow any apps that are associated with the provisioning profile to be tested on that device.
In this recipe, we will use iTunes to copy a provisioning profile to a connected device.
If you haven't already created a provisioning profile then refer to the Creating a development provisioning profile recipe before proceeding.
Launch iTunes and connect your iOS device through USB.
After a brief moment, the device will appear within the DEVICES section in iTunes.
Select File | Add File to Library (Ctrl + O | Cmd + O) from iTunes' drop-down menu.
Navigate to your
Documents
folder and select your provisioning profile at:packt\flash-ios-cookbook\developer-files\Flash_iOS_Cookbook.mobileprovision
. The provisioning profile will be added to iTunes.In the DEVICES section in iTunes, click on your device's name. You will be shown the device's summary information.
Click on the Sync button at the bottom-right corner of iTunes to copy the provisioning profile to your device.
A provisioning profile will only install on a device that is tied to that profile.
On your iOS device, you can confirm that the provisioning profile has been added by selecting Settings | General | Profiles. You should be able to see the profile listed along with its expiry date. If no provisioning profiles are installed on your device, then the Profiles option will not be made available.
When installing apps for testing, the app will be checked against the device's list of provisioning profiles first. It will only be copied onto the device if a provisioning profile associated with that app is found.
Once you are comfortable adding provisioning profiles to your devices, you may want to consider the following information.
You can remove provisioning profiles from your device through Settings | General | Profiles. Typically, you will want to do this when the profile expires. However, after removing a profile you may find that it re-appears on your device the next time it is synchronized with iTunes on your computer.
A copy of every provisioning profile you install is kept on your computer as well as your device. If you remove a profile from your device, then make sure you also remove the local copy from your computer.
Here is where provisioning profiles are stored:
Windows 7 and Vista:
C:\Users\<username>\AppData\Roaming\Apple Computer\MobileDevice\Provisioning Profiles\
Widows XP:
C:\Documents and Settings\<username>\AppData\Roaming\Apple Computer\MobileDevice\Provisioning Profiles\
Mac OS X:
<username>/Library/MobileDevice/Provisioning Profiles/
Simply delete the profiles using either Windows Explorer or Finder depending on your operating system.
As an alternative to iTunes, you may want to download and install the iPhone Configuration Utility from Apple.
It allows you to easily manage provisioning profiles and capture console log information from a connected device. You can check to see when a provisioning profile is about to expire and also discover which App ID is associated with each installed app.
The iPhone Configuration Utility is available for both Mac OS X and Windows and can be downloaded from www.apple.com/support/iphone/enterprise.