theboywhocriedWoolf | Tal Woolf

Compiling AIR with FDT and Ant


Automatically sync your apps to your mobile

Compiling AIR with FDT and Ant

When it comes to using technology we want things done fast, in the least amount of steps, and with minimal effort. So if like me you use eclipse and FDT to compile your AIR applications having to manually remove and reinstall your app onto a mobile device each time you want to test it can feel a little tedious, to say the least…

Unlike previous versions of FDT, FDT 4 really simplifies the process of creating mobile applications. You simply create a new flash project, select the mobile option and then the template you would like to use, entering the required information such as the location of your provisioning profile and .P12 certificate, then FDT does the rest. This process has nicely eradicated the need to trawl the Internet looking for ways to create an Ant script to compile your code and create the desired files.

If you’re unsure of how to create a provisioning profile or a .P12 certificate, Jeanette Stallons has written a nice explanation of this.

The problem here isn’t creating the IPA, as mentioned above FDT 4 takes care of all that for you, it’s the process that comes afterwards. Once created you still have to open it with iTunes or Xcode, make sure that previous versions of the app has been removed from your mobile device, then force iTunes to sync with your mobile to reinstall the latest modification of your app.

These simple steps would be fine if due to your superhuman planning you only had to test your app once before discovering it worked like a dream. But in reality this seldom happens and after the fifth or sixth revision, what seemed like a 5 minute process soon becomes unbearable 3 hours down the line, especially if you are making minor adjustments to animations or timings of tweens.

Can’t I just automate?

After much Google time, I discovered this was occurring due to the version number in my apps descriptor file remaining unchanged, making the mobile device think the app had already been installed, and therefore did not need to replace it.

Unless specified FDT automatically creates an application descriptor file for you whenever you debug or compile your app, the only difference for mobile is that after this happens FDT automatically instantiates Ant script to do the rest giving you your IPA.

If you take a closer look at an IOS mobile project created by FDT you’ll notice that the project folder contains a folder named “ant”. This folder contains three Ant scripts and a properties file that come as standard with any IOS mobile template. The three scripts coincide with the three compilation options provided by FDT to compile your code: test, debug and release.

I decided the best way to increment the version number in my apps descriptor file was to modify my Ant script, forcing incrementation to happen automatically each time the app was compiled. Even with this in place, there is still the need to open the IPA and get iTunes to sync to the mobile device so I figured why stop there…this is where the power of Ant shone through once more.

Prior to this I had only really used Ant to compile my SWF’s and create a custom HTML template, so I had to do a little research. Following a substantial amount of time reading blog posts and a lot of trial and error, (mostly error) I managed to accomplish both tasks using my Ant files.

On each compilation Ant reads the existing application descriptor file, takes a note of the version number, if a version does not already exists, it creates one, increments it, then compiles the IPA. Upon successful compilation Ant creates an AppleScript file on the fly, which opens the IPA, force iTunes to sync with the mobile device and then deletes the AppleScript file.

If you are interested and want to learn more about using Ant, to be able do this yourself, there some good articles about how to increment version numbers and using AppleScript to force iTunes to sync. I found “Automating ActionScript projects” a very informative resource for learning how to automate tasks with Ant.

Customisation is key!

This process worked well and at the touch of a button FDT compiled my app, opened iTunes and installed my app onto the mobile device. However, each time a new project was created the modified Ant scripts would have to be copied across. This was far too manual for my liking and started giving me undesirable flashbacks of using FDT 3.

To solve this, I created a custom project template that can now be used within FDT. Once installed it simply appears as an available option when creating any new mobile flash project. The template automatically includes all the modified Ant scripts and supporting files required to compile and sync your application to a mobile device.

Installation if you please

You can download my custom project template. Once you have downloaded it and unzipped the templates contents, you will find an AppleScript file called “runinstall” and an additional zip file containing all the required custom template files. Run the AppleScript file by double clicking (this just unpacks the custom template files into FDT’s template directory all ready for you to use) or if you prefer to do this yourself simply unzip the folder named “AS3 IOS With” and place it in the following directory: Library/application support/FDT/projectTemplates/. You can find further information about custom templates on the FDT website.

Now installed, when you go to create a new flash project, in eclipse, under the mobile option you’ll see a new selection available called AS3 IOS with sync select this and fill in the required fields just as before. Eclipse will now create your project using the custom template and consequently now when you compile your application FDT will automatically use the modified Ant files and then sync your app to your mobile device, each time incrementing the version number in your descriptor file. And that’s it, there is no more to it, you don’t even have to manually modify your descriptor file (unless of course to add specialised options or embed any assets).

project template exmaple

Mac only this time, sorry..

Unfortunately, because of the way I have modified my Ant script to use AppleScript when opening and syncing the IPA, these templates only work when using eclipse and FDT on a Mac.

But by all means all you Windows users out there feel free to modify the Ant script to use command line instead and let me know how you get on, Feedback is always welcome, ping me back if you have any problems.



  1. AreKavanagh

    A interesting post there mate ! Thanks for the post .


    I thought this was a little more elegant and extensible than writing to file – check it out.

Leave a Reply

(* Required)