Every one of us, who has developed an application for iOS using Adobe AIR, knows how long and painful is the process of testing the app on a iDevice. If you develop native obj-C applications using Xcode you can simply hit a button and the IDE will just build it and install it for you. The workflow for Flash developers instead, as suggested by Adobe itself is the following:
- Build the app using the launch method “On device” (either Standard or Fast)
- Uninstall the app from the device
- Go to iTunes (or any equivalent software) and drag-drop the generated ipa file in the Apps tab on the left sidebar
- Still from iTunes, go to the device tab and drag-drop the app onto the device screen (or select it in the left column) and hit “Sync”
Now, it might look easy, but if you think about doing it tens of times in a day, I assure you, it’s a real pain in the butt. Not just for the amount of time wasted, but also for the amount of clicks, drags, drops etc. What if you could just run a script from the terminal and then sit and relax, while the script does all the “dirty” job for you? After some research, I found this fantastic blog post from Tom Krcha, talking about good practices to compile, install and profile your app for iOS. Thanks to the links contained in the post I have built a simple bash script that I thought could be worthwhile sharing.
echo “# Compiler: Packaging app, Sir.”;
case $1 in
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package -target ipa-debug-interpreter -provisioning-profile PATH-TO-PROVISIONING-FILE -storetype pkcs12 -keystore PATH-TO-P12-CERTIFICATE – storepass “your-certificate-password” OUTPUT-IPA-PATH PATH-TO-XML-APP-DESCRIPTOR-FILE PATH-TO-SWF-FILE PATH-TO-OPTIONAL-ASSETS-FOLDER;
transporter_chief.rb OUTPUT-IPA-PATH;; #<— This will install your app on the device, so make sure it’s connected to your USB
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package –target ipa-app-store -provisioning-profile PATH-TO-PROVISIONING-FILE -storetype pkcs12 -keystore PATH-TO-P12-CERTIFICATE -storepass “your-certificate-password” OUTPUT-IPA-PATH PATH-TO-XML-APP-DESCRIPTOR-FILE PATH-TO-SWF-FILE PATH-TO-OPTIONAL-ASSETS-FOLDER;
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adl -runtime /Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/runtimes/air/mac -profile mobileDevice -screensize 768×1004:768×1024 -XscreenDPI 132 -XversionPlatform IOS PATH-TO-XML-APP-DESCRIPTOR-FILE PATH-TO_OUTPUT-FOLDER;;
Let’s see what it does: As you can see it’s just a simple Switch/Case statement. You can provide an optional argument [test | release] to the script, and you can see it represents one of the cases in the main Switch:
- If you pass “test” as an argument, the script will build your app using the quick method (note -target ipa-debug-interpreter) , the same you can select in the Flash Builder, which is fast but you know performances are ridiculous. Useful for quick tests.
- If you pass “release”, the script will build using the slow method (note –target ipa-app-store), which is slow but performances are optimal.
- If you don’t specify an argument, the switch will go through the default case “*)” and run you app in the desktop simulator (in this case simulating an iPad, as you can see from the argument -screensize 768×1004:768×1024)
The script makes use of the adt package command, whose documentation can be found here. It also uses transporter_chief.rb, a Ruby script that you can find here, to beam the compiled app to your device. Have a look at it and make it work as a first step. My script is just a simple idea to save time, you can build your own with some basic bash programming skills. Read the doc and create your own script to fit your needs, like different screenSize, or screenDPI, etc.. Hope you find it useful.