So you want to know what’s in an AIR Native Extension for iOS and how it fits together? I know, Adobe’s online manual has it all, which is great. It is also a problem, as you are left to sift through tones of pages of information, just to get a general idea.

This post is a collection of infographics, which will give you a bird’s eye view of how a native extension for iOS fits together. You can also use it as a checklist for the files and settings you need to set up in your extension.

What is an ActionScript Native Extension?

A library, packaged into an .ane file. ANE stands for ActionScript Native Extension. An ANE allows you to extend your mobile app with functionality, which is not available to you via ActionScript. To use an ANE, you package it into your iOS App Store package – the .ipa file that you put on your device or release on Apple’s App Store:

AIR iOS Native Extension - IPA overview

Wait, how do I implement the ANE, if ActionScript is not an option?

You use native code. When you implement a Native Extension for iOS, this would typically be Objective-C.

This is what goes in your Native Extension:

  1. You implement your extended functionality as a native library – an .a file for iOS. There you can make direct calls to the iOS SDK.
  2. Then you slap on an ActionScript interface on it. This will be an ActionScript AIR library – a .swf file, which will make calls into the AIR Runtime, which in turn will call the native code and pass results, arguments or events back to your AIR library.
  3. The native library and the AIR library get packaged together in an .ane file.

AIR iOS Native Extension - Layers

How do the libraries and the application code work together?

In order to get it all to click, you have to do some formal introductions.

Introduce the two native libraries to each other

  1. In the AIR library’s ActionScript code create an instance of flash.external.ExtensionContext. This is the class that you will be using to make calls into the native side.
    Tip: An ExtensionContext instance is created for a particular Extension ID and a particular Extension type and is passed as an argument to all calls into native code.
  2. Add Extension descriptors to your AIR library: these are two XML files with information about the extension and the native library:
    1. extension.xml contains an Extension ID – a unique string identifier, the name of the native library file and the names of the extension initializer and finalizer functions. The extension initializer and finalizer are called by the AIR runtime when the extension is loaded and unloaded, respectively. For details on what these look like and how they work have a look at our next post, Adobe AIR Native Extensions for iOS – Initialization and Finalization
    2. platformoptions.xml contains platform-specific information. For iOS this would include the version of the iOS SDK and a list of iOS SDK frameworks that the native library uses, for example:

AIR iOS Native Extension - extension descriptor

Introduce the ANE to the Air Mobile APP

  1. Add your Extension ID to the application descriptor file, normally called your-app-name-app.xml.
  2. Add the ANE to your project settings:
    1. add the path to the ANE to your Flex Build Path
    2. include the ANE in your Flex Build Packaging; here you may also have to add a path to the iOS SDK:

AIR iOS Native Extensions - App descriptor

Introductions done, now what?

Next, you will have to make it possible for the AIR Runtime to load and unload your extension. For this purpose you need to implement a couple of pairs of functions:

  • Extension Initializer and Finalizer
  • Extension Context Initializer and Finalizer

For what these are and how the AIR Runtime calls them, read our next post, Adobe AIR Native Extensions for iOS – Initialization and Finalization.

About the Author

Radoslava is co-founder of DiaDraw. Prefers to communicate with images. Verbal communication always caused trouble with her parents. Started speaking Basic early on, followed by four years of Delphi, six years of C++, four years of ActionScript, lately converses in Objective-C. Her mum and dad hope she'll start speaking human at some point.