Special thanks to Philipp for writing this tutorial.

Download the example project here!

Beginning with AIR 3.3, users are able to debug their iOS applications on device via USB. You will have to merge an AIR 3.3 SDK with your Flex 4.5 or 4.6 SDK in order to make it work. In FDT 5 you can use the FDT SDK merge feature for that. You can find it in the SDK preferences of FDT 5.

Restrictions

AIR 3.3 has just been released and neither FDT nor Flash Builder currently support usb debugging for iOS via the user interface. You are able to use the usb debug functionality of AIR 3.3 now via ant.
Please note: Installing, uninstalling and launching applications on your iOS device is not possible at all. Only the debug process can now be handled via USB. Therefore, you will still have to install your ipa on the target device via iTunes and launch it manually while.

Packaging For USB

The packaging for usb debugging does not differ much from packaging for wifi debugging. The only difference is that instead of the -connect argument you will have to pass -listen to the adt.

<target name=”01. package for usb debug”>
<exec executable=”${FDTProjectSdkPath}/bin/adt” failonerror=”true” dir=”../bin”>
<arg value=”-package” />
<arg value=”-target” />
<arg value=”ipa-debug-interpreter” />
<arg value=”-listen” />
<arg value=”-provisioning-profile” />
<arg value=”../certificates/SandboxPA.mobileprovision” />
<arg value=”-storetype” />
<arg value=”pkcs12″ />
<arg value=”-keystore” />
<arg value=”../certificates/myCert.p12″ />
<arg value=”-storepass” />
<arg value=”myPassword” />
<arg value=”AIR33features.ipa” />
<arg value=”AIR33features-app.xml” />
<arg value=”AIR33features.swf” />
</exec>
</target>

Receive The Device Handle

In order to connect the debugger to your device via usb you will need to find out the device handle and forward the ports between your machine and the device. The tool idb that is included in your Flex SDK will do that for you. The following ant call will return your device handle and the UUID of your device

<target name=”02. show connected devices”>
<fdt.loadProjectProperties projectname=”AIR33Features” />
<exec executable=”${FDTProjectSdkPath}/lib/aot/idb/idb”>
<arg value=”-devices” />
</exec>
</target>

This will return something like this, depending on how many iOS devices you have connected.
02. show connected devices:


[exec] List of attached devices
[exec] Handle    UUID
[exec]     4      b47b4c4fe1a664e923f6fa3df90b20f1a8r45cdc
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 1 second

After you have received your device handle you can use idb to forward the necessary ports. The first port passed to idb is the local port you will use for debugging your application, the second one is the one you specified during packaging. If you haven’t specified one its 7936. The third one is the device handle you received in the previous step.
Before you run the below task, make sure that your application is already running on your device and waiting for the debugger to connect.

<target name=”04. forward ports for USB debug”>
<exec executable=”${FDTProjectSdkPath}/lib/aot/idb/idb” >
<arg value=”-forward” />
<arg value=”7936″ />
<arg value=”7936″ />
<arg value=”4″ />
</exec>
</target>

Start Debugging
The last step is to manually start up FDTs debugger and let is to ask for a connection to the application via USB. You can do so by putting the debugger into client mode and pass it the local port to use

<target name=”05. start FDT debugger for usb debug”>
<fdt.startDebugger projectname=”AIR33Features” port=”7936″ asclient=”true”/>
</target>

The debugger should connect to your application and you are able to debug it like you are used to with the wifi debug.