Debugging AIR apps on iDevices with Flash Builder 4 or Burrito
NOTE: Future versions of Flash Builder might handle this workflow better. For example debugging AIR for Android applications in Flash Builder Burrito is much easier.
The process to debug your AIR applications running on a iDevice (iPhone, iPod, iPad) is very similar to the steps you needed for AIR for Android with Flash Builder 4 (Flash Builder Burrito can also be used with these steps, and is the future of mobile workflow for Flash Builder).
Packager for iPhone (aka: pfi) can be downloaded on labs.adobe.com.
There is a couple of steps to make this happen but the idea is broken down here:
- Connect iDevice to the same network as desktop with Flash Builder, and lookup the desktop ip address.
- Compile application for debugging, both mxmlc -debug and pfi -package -target ipa-debug.
- Put the debug version of the application on the iDevice device.
- Configure the project in Flash Builder to launch debugger with out launching the Application.
- Launch newly configured project.
- Launch AIR application on the iDevice device.
- (depends if you use correct value in -connect with adt) Enter IP of Flash Builder machine and click button.
The Detailed Steps
I first made sure that my iDevice was connected to my local wifi network. Then I retrieved my desktop’s ip address of value 192.168.1.100, which I’ll use in a second.
Before packaging the AIR for iDevices application with
pfi, you’ll need to create a debug swf. By default the Flash Builder creates a debug SWF in the “bin-debug” folder. You can use this version of the SWF in the packaging arguments of pfi or if you are packaging with mxmlc from the command line all you need to add is “-debug” to the compiler arguments. Here is a part from my shell script (Mac OS X could be modified for Windows command line) compile.sh found in the source code provide with this post:
$AIR_SDK/bin/amxmlc -target-player 10.0.0 -debug DebugDemoPFI.as[/php]
You’ll note that it’s using “amxmlc”, which is just a wrapper around mxmlc with configuration files pointed to include AIR libraries. Now we have a debug version of the SWF file, onto packaging a debug version of the ipa.
[php]$PFI_LOC/bin/pfi -package -target ipa-debug -connect 192.168.1.100 -provisioning-profile YourDev.mobileprovision -storetype pkcs12 -keystore your_cert_2010.p12 -storepass password DebugDemoPFI.ipa DebugDemoPFI-app.xml DebugDemoPFI.swf Default.png icon29.png icon57.png icon512.png[/php]
-target ipa-debug -connect 192.168.1.100 are the critical parts. The
-connect argument can take the form of a domain name, ip address, or “…”. The last options allows for you to set the IP address at runtime.
Compiling the Application and Getting it on the iDevice
Plug the iDevice into the computer with the usb cable. Grab the Flash Builder 4 DebugDemoPFI.zip project code. Import project to Flash Builder 4 and make note of the project’s folder location. In the project files you’ll find a compile.sh file. Open a command line and navigate to the project’s folder location. Change the compile.sh’s permissions to allow for running it as a script (
chmod 755 compile.sh will work). Open up the compile.sh file for editing and change the appropriate paths to your Flex/AIR SDK, PFI location, connect ip address, and the location of your Apple Developer signing certificate, provisioning file and password. After configuring your version of compile.sh correctly, change your directory location (
cd src) into the src folder location and then do:
After the DebugDemoPFI.ipa file has been created then copy the file over to iTunes and added/sync it to your iDevice.
You should be able to go onto your device and run the application and see 2 squares and a text field.
Starting a Flash Builder Debugger Session
The steps to configure and launch the debug session are outlined in another post, read the section “Starting a Flash Builder Debugger Session”.
Just use DebugDemoPFI when it says DebugDemo.
NOTE: I used ActionScript 3 project in this post because currently Flex has issues when packaging an ipa with a debug SWF. The steps are the same once the Flex issue is resolved in the future.
Example of how to use pfi in the command line:
$AIR_SDK/bin/amxmlc -target-player 10.0.0 -debug DebugDemoPFI.as
$PFI_LOC/bin/pfi -package -target ipa-debug -connect 192.168.1.100 -provisioning-profile YourDev.mobileprovision -storetype pkcs12 -keystore your_cert_2010.p12 -storepass password DebugDemoPFI.ipa DebugDemoPFI-app.xml DebugDemoPFI.swf Default.png icon29.png icon57.png icon512.png