I’ve just spent the day learning about AIR Native Extensions. The idea is to build an Iphone app with a Flash Builder interface but using native Iphone audio capabilities. It seems that globally things have been well thought out and executed, but there’s one thing that comes across as amazingly pre-alpha craptastic: packaging your native extension. It also happens to be the worst documented, and apparently the worst understood by Adobe’s own team as their articles on the subject are misguided and confused.

The basic bricks you need for an ios only native extension are :

  • an XCode project where you code your native functionality
  • a Flash Builder Library project where you write the AS code that serves as a bridge

And then you would expect that you could point the Library project to your compiled native library, and it would produce a ANE file, ready to use. Right? Right? No.

You have to use a command line tool called ‘adt’, that comes with your AIR SDK. Fair enough. Along with a descriptor XML file. Up to there you grudgingly admit that this is new technology and that you have to put up with half-finished stuff, but where things fall to pieces is where you start dealing with the mysterious “library.swf”.

This is actually a swf that you must yourself manually extract from the swc. WTF Adobe, can’t your adt tool do this itself? So anyway: take a command line tool like 7zip and extract library.swf from your swc, and then use it in your command line. The doc mentions that the library.swf file can be different for each targeted platform. Really, I can’t what design would justify having different AS3 APIs for different platforms, but I’m new to this. Still seems harebrained though.

So after jumping through all the hoops, I ended up with the following error:

Unable to build a valid certificate chain for the signer.

Fear not, what the tutorials don’t tell you is that signing an ANE is optional! So if your signing fails, you can still use your ANE yourself, just remove the signing.

One last (bonus) hoop: The packaging settings are supposed to detect whether or not an ANE is used. At least in my test here it says it isn’t being used even if it, so don’t hesitate to tell Flash Builder to include the ANE anyway.

This article helped me the most, even if it’s for Android, not Ios.

http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html

So I worked with this example :

http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/gyroscope.html

Below is my version of ./package.sh as mentioned in the article, in case it can help someone.

adt_directory=”/Applications/Adobe Flash Builder 4.6/sdks/4.6.0/bin”

root_directory=”/Users/arielsommeria-klein/Documents/workspaces/tests/Vibration/VibrationNEDeliverables”

library_directory=${root_directory}/VibrationActionScriptLibrary

native_directory=${root_directory}/VibrationiOSLibrary

#signing_options=”-storetype pkcs12 -keystore /Users/arielsommeria-klein/Documents/ios/certs/ariel-ios.p12″
dest_ANE=NetworkInfo.ane
extension_XML=${library_directory}/src/extension.xml
library_SWC=${library_directory}/bin/VibrationActionScriptLibrary.swc

“${adt_directory}”/adt -package -target ane “${dest_ANE}” “${extension_XML}” -swc “${library_SWC}” -platform iPhone-ARM -C “${native_directory}” .
#”${adt_directory}”/adt -package ${signing_options} -target ane “${dest_ANE}” “${extension_XML}” -swc “${library_SWC}” -platform iPhone-ARM -C “${native_directory}” .

Pin It