One of AIR 3.3’s new features enables you to test your applications directly on the iOS Simulator shipped with Xcode. This dramatically increases the speed in which you can preview your applications, eradicating that tedious pause between shifting a pixel in your code and seeing the result on device.
But remember, there is no substitute for the real thing. Make sure you always test on device otherwise, who knows, you could end up releasing a tame app into the wild not knowing if it can fend for itself.
Testing on the simulator has been made possible through the implementation of two extra compilation targets, that are now built into ADT shipped with the latest AIR SDK. You can find detailed posts by Tom Krcha and on the Adobe blog that take you through a step by step process of how to use these when compiling your applications.
However, if like me you try and avoid using command-line as much as possible, mainly because of the tedious task of having to remember the location of all the files you need, and then having to keep track of all the windows you have open to remind you of the necessary file locations, in the first instance, just to compile an IPA AND then having to go through this process all over again to eventually deploy the IPA onto my device (phew). Then like me, you will also realise the importance of automation.
Automate that Sucker
My previous post concentrated on Customising an FDT Template to enable you to automate the process of synchronising your applications to your device, through iTunes, removing the intermediary process of having to manually remove your previous app and forcing iTunes to update your device. My new AS3 AIR iOS Template takes that further, all with that vital goal of providing easy compilation of your AIR applications at the touch of a button, or click shall I say?
The new AS3 AIR iOS Template I created provides you with all the same debugging features currently available through the standard iOS Mobile Development Template shipped with FDT, while also implementing AIR 3.3’s new features. It automates the process of building and deploying your app using behind the scenes ANT Script, which takes care of all the command-line scripting for you, while also bypassing that beast we all love to hate iTunes, when installing your app to device vastly improving deployment speed.
The Template provides you with the following compilation options:
1) Test on Device – standard FDT
2) Wireless Debug on Device – standard DT
3) Test on Simulator
4) Debug on Simulator
5) Remote USB Debugging on Device
6) Release to Device – standard FDT
You’ll notice that as well as AIR’s new Simulator deployment I included a Remote Debugging option. At the time of creating the Template I started reading Tom Krcha’s blog post on Remote Debugging through USB and thought that this too would be a nice feature to have, mainly as it involved multiple steps using command-line actions which I quite frankly couldn’t be bothered to repeat each time I wanted to debug my application.
Get the Ingredients
Before you can use the template you must make sure that you have Ruby, Git and Make installed on your MAC. The AS3 AIR iOS Template now uses a handy little Ruby Script called Transporter Chief that performs command-line installation of the IPA onto the device instead of going through iTunes, removing the need to increment the application version number as in the previous Template.
To check you have these installed type the following into Terminal:
make –help git –help
If both return a result then you are good and ready to continue with the Template, if not simply enter the following into a Terminal window:
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
If you would like to get a full explanation of what just happened then check out “How to deploy iOS apps to the iPhone using command-line” by Holger Weissbock.
Lets start Baking
The Custom AS3 AIR iOS Template, once unzipped, can easily be installed. Simply run the “runinstall” AppleScript file located within the download folder and you are ready to go. As my previous post stipulates all the AppleScript does is install the Custom Template folder in FDT’s Template folder location geared up for you to use.
Once the Template is in place, within FDT, start a New Flash Project as usual. Although this time when you select the Mobile option you will notice that the AS3 AIR iOS Template is available as a new option on the right hand side.
Select this Template and start populating the required fields as before, providing the location of the Developer Certificate, and Provisioning Profile as you would with the standard iOS Mobile Template. You will notice that there are a few extra fields here, these are:
- AIR 3.3 SDK
- Debug Port
- Handle ID
AIR 3.3 SDK is simply the path to your new AIR SDK folder. You need to provide this in order for the compiler to take advantage of AIR’s new SDK features. You cannot just combine the AIR SDK with your Flex SDK as you may have done in the past as this for some reason does not seem to work. So make sure that you keep your Fles SDK and AIR3.3 SDK separate in your libs folder or wherever you choose to store your SDK’s.
Debug Port can be left as it is and is used for Remote Debugging only. You can if you want specify a forwarding port but 7936 is the default and works just fine.
Handle ID is the ID given to your device automatically when you connect it through USB. I recommend you leave this field blank as the Templates ANT Script will search for this value and populate this field automatically on each compilation. If you do enter the ID manually you must make sure you go within ANT’s properties file and change this each time you disconnect and reconnect your device. If you are happy to do this, then by all means populate this field; it will shave off about two milliseconds during compilation so the choice is yours.
I will take you through Remote Debugging with the Template further on, but if you want to know the command-line tools available to manually get the Handler ID and further information with regards to this, I encourage you to read Tom Krch’s post Using USB Debugging in AIR 3.3 for iOS.
Deploy if you Dare
Now that the Template is installed and all the options are correctly populated you are ready to start developing whatever application you have chosen or have been tasked to make.
When you go to debug your application you will notice all the usual debugging options are the same as with the standard iOS Mobile Development Template, the only difference being when you select one of these the IPA will be created and installed directly on to you connected device.
You will also notice the two new debugging options for AIR 3.3; Wireless Debug on Simulator and Test on Simulator. These do exactly what they say on the FDT Debug Configurations tin, installing your IPA directly onto the Simulator ready for you to preview and test.
For best results make sure the Simulator is already open, as it can sometimes cause a few timeout issues within the ANT Script, due to its lengthy initialisation. You may rarely experience a few problems as the device, for reasons unbeknown to me, seems to behave oddly at times. In this instance just recompile and or reboot the simulator and this tends to fix any issues.
To debug your application using Remote Debugging select the option as you would any other from the Debug Configurations window. Once the IPA is created and installed onto your device a terminal window will pop up automatically instantiating the Flex FDB command-line Debugger.
Open the application on your mobile device and you will be met by a popup message advising you that the application is waiting to connect to the debugger. Once the application is running, press r and Return within the Terminal window. Your application should now be connected to the debugger and advise you accordingly. All that’s left to do now type “continue” and Return within the Terminal window and you are ready to go, your app is now connected remotely to the command-line Debugging console.
And that’s it…you should now be up and running! I know it seems like you have followed the yellow brick road all the way to OZ, but I hope you now feel your journey was worth it in the end and you have found your shiny red slippers.
Download the AS3 AIR iOS Template, or Spoon me on GitHub to see the Template files for yourself. I have also included the AS3 AIR iOS.zip and the “runinstall” AppleScript, so you can still install the Template by downloading the uncompressed Template files. Happy Debugging.