Debugging AIR apps on iDevices with Flash Builder 4 or Burrito

Posted on November 15, 2010 | 6 comments

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:

[php]
USER_WORKSPACE=/Users/renaun/Documents/workspaces
PFI_LOC=$USER_WORKSPACE/iPhoneDev/packagers/packagerforiphone_v1_mac_20101001
AIR_SDK=$USER_WORKSPACE/FlexSDKs/flex_sdk_4.1.0.16076_air25

$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]

The -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:

>../compile.sh

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:
[php]
USER_WORKSPACE=/Users/renaun/Documents/workspaces
PFI_LOC=$USER_WORKSPACE/iPhoneDev/packagers/packagerforiphone_v1_mac_20101001
AIR_SDK=$USER_WORKSPACE/FlexSDKs/flex_sdk_4.1.0.16076_air25

$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
[/php]

  • Robert

    Hey, great to know about this!

    I’ve done some research anywhere may I know what framework should I be using for mobile advertising using flash packager for iOS? is iAd available? if not can you suggest me with anything that’s available and also for android device. I just can’t found anything and no reply from adobe forum. So stuck and need urgent info on this. Thanks in advance!

    • http://www.renaun.com Renaun Erickson

      I do not have a good answer for you on this one. At one point Greystripe was doing on an AIR for Packager for iPhone AIR and I believe they did and Android one, but i haven’t used it. http://www.greystripe.com/

  • Robert

    Thanks for your reply Renaun. That at least give us some indication. Keep up the good work!

  • http://www.dobieag.com Mark

    I’m still a bit confused how you compiled your SWF in Burrito and got PFI to compile it. I can’t get PFI to work with AIR 2.5. I saw that your app.xml referenced version 2.0 which didn’t really help clarify things :)

    I guess a clarification question would be, “Did you compile with the latest AIR SDK and compile that SWF into an IPA?”

    Also, what exactly are the “issues” with packaging an IPA using a debug SWF from Flex?

    • http://www.renaun.com Renaun Erickson

      For the exact issues with the Flex debug SWF’s check out this post – http://renaun.com/blog/2010/11/flex-with-packager-for-iphone-tips/

      So pfi is like a separate sdk. You need to download the Packager for iPhone bits from http://labs.adobe.com/technologies/packagerforiphone/

      I have updated the post to make it more clear about where to get pfi. Its like a sdk in the since you can find the pfi packager tool in the bin/ folder and then you use it like adt. Look in the example project for this post and open up the compile.sh shell script file in the project root folder to see an example (also posted above in updated post).

      • http://www.dobieag.com Mark

        Rock on Renaun! Thanks for this!

  • Pingback: Flash Tutorial: How to Debug AIR apps on iDevices with Flash Builder 4 or Burrito | Adobe Flash Lite