Tips for iOS AIR Development

Posted on March 29, 2011 | 1 comment

With the update to iOS development with AIR 2.6 developers can now package iOS applications with the same tool, called adt, that is used for desktop AIR applications. The main difference with the iOS target is that some cross compilation is happening along with the packaging. This does take some time, but another part of the iOS development time suck is getting the packaged .ipa on the device.

If you are finding yourself deleting/removing your development application from iTunes or the device each time to test that application you will want to read on.

The trick is to increment the versionNumber in the application descriptor file before pushing to iTunes. If the versionNumber of the application is higher then the last one in iTunes it will update when you click sync, no need to delete first. And then on Mac there are some AppleScripts that are useful to force the install and prompt to replace which if the versionNumber is higher will sync right then.

Incrementing the versionNumber in app.xml

There are a few options here but what has worked for me is to increment, for iOS, the versionNumber as 1.1-1.9999. I haven’t fully tested what values don’t work but have had problems in the past so I stick to this pattern. Sometimes I just edit the versionNumber by hand but there are ways if you are using ANT or shell scripts to make this easier.

ANT approach

Shell script approach, requires a counter file with just one line with a number on it:

count=`cat counter`
echo "COUNT: $count"
echo $((count+1)) > counter
# Application Name


sed "s/$OLD/$count/g" $appname-app.xml > $appname-appV.xml

With the application descriptor file looking like:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="">

Packaging with adt

This is how you always do it with all the arguments passed into adt to package your application. Here is what I have in my shell script:

count=`cat counter`
echo "COUNT: $count"
echo $((count+1)) > counter

# Application Name

# COMPILE TYPE ( ipa-test | ipa-debug | ipa-app-store | ipa-ad-hoc )


sed "s/$OLD/$count/g" $appname-app.xml > $appname-appV.xml


rm -Rf *.ipa

startTime=`eval date +%s`

$AIR_SDK/bin/adt -version
$AIR_SDK/bin/adt -package -target $COMPILE_TYPE -provisioning-profile $IPHONE_DEV/RenaunDev.mobileprovision -storetype pkcs12 -keystore $IPHONE_DEV/my_cert.p12 -storepass password $appname.ipa $appname-appV.xml $appname.swf Default.png icon29.png icon57.png icon512.png

endTime=`eval date +%s`
let PTIME=($endTime - $startTime)
echo "COMPILE: $PTIME secs"

MAC ONLY: AppleScript to push and force a sync to iTunes

Now with the packaged ipa getting a new number and ready to get on to the device we hit the gatekeeper, iTunes. On a mac if you type in the terminal “open my.ipa” it will open it up in iTunes. Then there is some iTunes specific AppleScript (I wish there was more with apps in iTunes as most AppleScript is music related) to force the sync. Here is the end of my shell script that has the AppleScript:

#echo "Opening IPA in iTunes"
open $appname.ipa
osascript -e 'tell application "iTunes" to update "ikaibab"'

Viewing versionNumber in the Application

If you want to make sure the apps on the device are being updated what you want to do is access the application descriptor file and view the versionNumber. Its not the most straightforward piece of code but here is what you need:

import flash.desktop.NativeApplication;
// I put this in a try/catch so it does break SWF desktop testing with non-AIR testing
    var descriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
    var ns:Namespace = descriptor.namespaceDeclarations()[0];
    versionNumber = descriptor.ns::versionNumber;
} catch(error:Error) {  }

Here is the full bash script on snipplr.

  • Pingback: AIR development za iOS – što valja znati? | Hrvatska Flex zajednica -

  • Billy Deakin

    Hi Renaun

    Very useful post, I have indeed been deleting the app from iTunes and the device each time so this is a real time saver!

    I have a totally unrelated problem which wonder if you can help with. I can’t get the “Full Screen” option to work!

    I set the fullScreen node to full exactly like in your example descriptor above, but ass soon as the loading screen vanishes the toolbar appears.

    So am I doing something wrong, or is this a bug in the adt?