Debugging AIR applications over USB on iOS

With the release of AIR 3.3, it is now possible for developers to debug their iOS AIR applications over a USB cable on the device. Prior to this release developers had to use wifi for debugging an AIR application on the iOS Device. There were, however, a few limitations associated with wifi debugging.

1) A developer needs to have internet connection available all the time.
2) Both the device and the desktop machine must be on the same subnet.

This new capability will solve the above mentioned problems and will provide a seamless debugging experience to the user by just connecting the iOS device to a Mac or a Windows machine. Since this feature is not available in Flash Builder or Flash Professional at the moment, a developer has to perform certain steps to get the debugging over USB working.

The steps required to set up the debugging over USB are as follows:

Package the application

While packaging the application one would need to specify “-listen <port_number>” option instead of “-connect <host_name>” which is used in case of wifi debugging.

adt -package -target ipa-debug
       -listen 9999
       -provisioning-profile <_prov_>.mobileprovision
       -storetype pkcs12 -keystore <_cert_>.p12 -storepass <_password_>
       Test.ipa Test-app.xml Test.swf

Install the application

Install the application using iTunes. Upon launching the application, one will see a dialog saying that ADOBE AIR is waiting for connection. The application waits for 60 seconds for the FDB(Flash Debugger) to connect at the port specified during the packaging. If no client connects, the application times out and launches as usual.

 

 Get Device ID

A new binary named idb is shipped with the SDK, and it is present at the following location “”lib\aot\idb\idb”. Running this binary with the “-devices” option will give the list of the devices attached to the machine with Device ID and UUID.

./idb -devices

List of attached devices
Handle    UUID
    33    {UUID of device)
    34    {UUID of device)

Forward the Local Port

In order to create a connection between the device and the machine, one needs to forward the local port of the desktop machine to the remote port (i.e the port on which the application is listening) on the device. This can be done using the idb binary. Since there can be a large number of devices attached to the machine, one needs to specify the device id while forwarding the port so that a connection with the specified device is established.

idb -forward <local_port> <remote_port> <device_id>
idb -forward 8999 9999 2

Start Flash Debugger (fdb)

Once the port is forwarded, we need to start the Flash Debugger(fdb) present in the SDK.

fdb -p 8999

On executing above command fdb prompt will show up and “run” command needs to be executed

(fdb) run
 Player connected; session starting.
 Set breakpoints and then type 'continue' to resume the session.
[SWF] Test.swf - 1,436,428 bytes after decompression

Now one needs to specify the name of the <function> or the<filename:linenumber> to debug

(fdb) break my_func

Following output will be shown on the pormpt.

Breakpoint 1 created, but not yet resolved.
The breakpoint will be resolved when the corresponding file or function is loaded.

The session should then be continued by executing “continue” command.

(fdb)c

This would indicate that the debug session is established. All one needs to do is to perform some action on the application which will hit the function mention in the break command.

And one is good to go with further debugging.

4 Responses to Debugging AIR applications over USB on iOS

  1. I think very useful article, thanks for sharing

  2. mihir says:

    when i forward

    ./idb -forward 5901 5901 3 the control doesn’t return after waiting even 10 minutes i have to abort it by ctrl + C … what could be the problem ?

    • rmahajan says:

      This is expected behavior and is not a problem as when ./idb forward LOCAL_PORT REMOTE_PORT DEVICE_HANDLE command is executed, a server is started which waits indefinitely for the clients to connect to it.

      In order to stop this process, use idb -stopforward LOCAL_PORT.
      Hope this helps.

  3. Ed says:

    Again, just another way APPLE makes things ridiculous!