Using FDT 5.6 AIR for iOS Project Template

Hello Everyone,

I know my blog posting has been kind of slow this last months but I promise I’ll make it up for all my readers, part of my latest work  have  included  a few Starling projects for mobile devices and can’t wait to share my findings with You all.
That said, let’s move on to the subject of this post.

In this blog post I’m going to show You how easy is to set up and publish an AIR for iOS project in FDT 5.6, in previous versions of FDT if You wanted to publish Your AIR application for iOS (.ipa file) You needed to create Your own ANT task file or use some custom project template, FDT 5.5 introduced new mobile project templates, one of them is the AIR for iOS Project Template that let’s You easily create, set up, debug and publish Your AIR for iOS projects.

So let’s get started!

Step 1.

First You need to create a new FDT Project, You can do so by going to the upper menu  then File > New > New FDT Project (see Fig .1  below) this will open the New FDT Project panel which leads us to step 2.

New Project
Fig.1

Step 2.

The New FDT Project panel (See Fig.2 below) is where You set your project’s name, it’s location, kind of project template, SDK, etc. For my project’s name I choose AIRForIOSExample and used the default location in the template selection part You must choose AIR > iOS this will setup a basic project targeting the iOS platform.

In the Application Setup  for  Application ID I used a reverse domain name of com.swfgeek.examples for  this will set Your package structure so give it the “path” that you’ll be using in your project. for Application Title I used AIR For IOS Template  and leaved Application Version as is.

In the Project Setup part choose the Flex SDK that You’ll be using, if You want to taget iOS 5.1 You’ll be needing at least AIR 3.3 included in your SDK.

You can download this combined version of the Flex and AIR SDKs (Flex SDK 4.6.0.23201 and AIR 3.4.0.2710 SDK) from Adobe’s Gaming Site  if You want to save the trouble of finding and merging SDKs.

Once done with these settings click the finish button.

New FDT Project Panel
Fig.2

Step 3.

Open Your main class ActionScript file, mine is located at “com.swfgeek.examples” and it’s named AIRforIOSExample for this example we  will be only adding some text in order to display something on screen once we are testing our project. You can copy the ActionScript below or add your own.

?View Code ACTIONSCRIPT3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.swfgeek.examples {
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
 
	public class AIRforIOSExample extends Sprite {
		public function AIRforIOSExample() {
			var tFormat : TextFormat = new TextFormat();
			tFormat.align = TextFormatAlign.CENTER;
			tFormat.color = 0xFF0000;
			tFormat.size = 45;
 
			var tField : TextField = new TextField();
			tField.x = stage.stageWidth * .5 - tField.width * .5;
			tField.y = stage.stageHeight * .5 - tField.height * .5;
			tField.autoSize = TextFieldAutoSize.CENTER;
			tField.text = "Hello iOS!";
 
			addChild(tField);
			tField.setTextFormat(tFormat);
		}
	}
}

If You used this script You’ll see a text in red saying “Hello iOS!” centered on screen once you test your application, how to test and publish? keep reading below.

 

Step 4.

Time for testing, to test/debug Your application on the AIR Debug Launcher (ADL for short) you must create a new debug/run configuration, you can do so by going to Menu>Run>Debug Configurations or clicking on the little bug icon on the upper toolbar  ( see Fig.3 below) and select Debug Configurations.

Fig.3

Here You will select FDT AIR Application from the left and click on the new icon on the upper left, this will  create a new debug configuration with Your project’s name ( see Fig.4 below). You can give it a different name and select a different class as your main application class, i’ll leave the one we just created so i can see the text we created in the previous step.

The Debug Configurations Panel
Fig.4

Now You must choose your primary Target Platform which is Apple iOS. On the Launch Method section You must select the launch method this will be either Desktop or on Device we will be focusing on Desktop for now.

You can select Custom size and  set Your device dimensions manually or select one of the included Mobile Presets i will select Apple iPhone  but you can also choose a different size  depending on  what device you need to simulate, the options are: Apple iPad 1/2, Apple iPad 3, Apple iPhoneApple iPhoneRetina and Apple iPhone.  See Fig.5 below.

Launch Method
Fig.5

With all set hit the Debug button (down left corner) give it a few seconds to compile and you should be seeing the ADL opening Your application on the selected simulator size (Apple iPhone) like Fig.6 below.

Fig.6

Step 5.

Ok so You’ve got your application running nice and smooth on your Desktop, you wrote a few traces to see the debugger pop those messages in the console, everything is working great but now you need to actually test your app on a physical device. Let’s setup things to do so.

To compile and export Your application to an .ipa file You need to be enrolled in the Apple iOS Developer Program, have a certificate in .p12 and the mobile provisioning profile of Your application, how to do so it’s outside of the scope of this tutorial and You can find plenty of examples on the web on getting your certificate ready for AIR development.  

So now that You have your Apple certificate and your application provisioning profile ready You must set AIR Properties for Your project, You can do this by opening the Launch Configuration window (check Step 4.) scroll down and click on the Configure project properties button or by right clicking in your project’s main folder and click on the Properties button located at the very bottom of the contextual menu ( see Fig.7).

Fig.7

Either way You choose will open up the Project Properties panel once is open click on the FDT AIR Properties on the left side and click the iOS button ( see Fig. 8 below).

FDT AIR Properties Panel
Fig.8

The first tab you’ll see once iOS is selected is the Building tab here you can set Your Application Description file ( FDT created one for You when You started Your project) You can browse to locate your descriptor in your system or click the create button and let FDT create it for you. Just below that box is the SWF File Name box where you enter your application’s main .SWF file.

Next to the right is the Properties tab ( see Fig. 9 below).

Properties tab.
Fig.9

In this window You must set:

Application Name ( the one that will appear below your application icon once is on the iPad/iPhone) the File Name (the name of the .ipa file).

The Application ID (This is the ID You gave to Your application in Apple’s Developer Center when You created your provisioning profile) Note: It’s important to remember that this might differ from the package structure that you gave to your project if You enter an ID different from the one you specified in Apple’s Developer Center Your application will fail to install on your device. 

The Air SDK Namespace is the version of AIR that will be defined in your descriptor file You can leave it as is ( it will use the number of the AIR SDK that you defined when creating your project).

The Version number of your project.

The Aspect Ratio here you can choose between portrait, lanscape or default depending on the aspect ratio of your application.

There are two checkboxes to choose if your application will be Full Screen and support Auto Orientation

Next is the Rendering Mode selector, you can select auto, gpu, direct or cpu depending on the rendering mode you want the application to run.

The Devices selector let’s you choose the iOS devices in which your application is supported the options are: iPhone/iPod, iPad and iPhone/iPod/iPad .

And the last one is the Resolution to choose high or standard resolution. Note: If you choose high but not prepare Your files (graphics) for the iOS higher resolution your application can look pixelated/blurry when running in an iOS retina device.

Digital Signature Tab
Fig.10

The next tab is the Digital Signature ( See Fig. 10) where you need to add the files provided to You by Apple in the Developer Center.

The first section of that panel in the Development Profile in the Certificate enter the path to where you have your iOs certificate .p12 file or use the button next to it to browse your system and find that file.

The second section is the Password field and here you need to enter the password you generated when creating you .p12 file yo can use the checkbox so FDT remembers it in the current development session.

Next is the Provisioning Profile field, the same as the development profile, enter directly on the field or use the Browse button to set the path to your .movileprovision file.

Below that section You can enter a different  iOS certificate and Distribution  profile (That will be a different one than the provisioning one) in order to publish a Release/Ad Hoc distribution file.

The next tab is the Icons one ( see Fig. 11 ) here you must browse for each one of the icon files in the corresponding size.

Fig.11

 

The next tab Package Contents (Fig.12 ) is where you can browse and add any additional file required by your application: images, xml, swf, swc, audio files, etc. In the Add Directory section you can also choose a folder and all files in it will be included in your .ipa file.

Fig.12

 

Next is the Extensions tab (Fig. 13) where You can add ANE (Short for Application Native Extension) files in case your application uses one.

Fig.13

 

And the last one is the Deploy tab (See Fig.4 below)

Deploy Tab
Fig.14

The first thing on that tab is the Pre package launcher where you must select the last run configuration before building the .IPA  file here you must select one of the “Run Configurations” to make sure the final file does not include a debug version of your .SWF.

In the Package Type  you get to select if is a final distribution release (the one that goes to Apple for approval and release on the App Store) or an Ad hoc package for testing and limited distribution.

Next is the Platform SDK where You can select and use the iOS SDK that Your application will be using.

And finally the Export Application section where you choose the place in your hard drive where your .IPA file will be saved.

 

Step 6.

Time to package and deploy.

Now You’re ready to package and export your application  in orded to do so you need to open up the Run configuration window ( See Fig.5) but this time instead of choosing On desktop as Launch Method you will select On Device (See Fig. 15 below) and here you can select two different package methods Standard (packaging takes longer & application performance is similar to deploy build) or Fast (packaging is quick & runs slower  than a deploy build) for testing is ok to use the Fast method but if you need to measure performance on the device is best to go with the Standard method.

 

On Device Launch Method
Fig.15

Then hit The Apply button and then click on the Run button, you will see the AIR compile process in your Console window ( See. Fig. 16)

Console Window
Fig.16

 

If you packaged it for debug you will see a pop-up window (See Fig. 17)  it will wait for you to install the application in your device and when ready hit the Start Debugger button to begin debugging Your application( Note: There are quite a few methods of installing an application on an iOS device without the cumbersome process of installing it via iTunes, you can install it directly via ADL using the Terminal for example but that will be matter that we’ll takle in another tutorial .

If You packaged your .IPA for deploy  your work is ready to install (See Fig. 18).

Fig.18

 

Hope it clears out how to use the AIR Project Template for iOS on FDT5.6 , write any issues of this process or further questions in the comments below  or You can always reach me on twitter as @swfgeek.

 

Thanks for reading and Happy Coding.
Dave