What goes into an AIR Native Extension for iOS?

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

We saw what an AIR Native Extension (ANE) is and how it fits in your app. Now let us zoom in and see what’s under the hood of an ANE for iOS.

There are two main components that you need to provide, in order to make an ANE for iOS:

  • an AIR library, compiled as a .swf file;
  • a native C, C++ or Objective-C library, compiled as an .a file.

A third component that enables the communication between the AIR and the native library is provided for you:

  • the AIR C API.

These three, together with a couple of descriptor files that, simplistically put, help the two libraries find one another, are packaged in an .ane file – the actual AIR Native Extension.

The AIR library

The AIR library component of an ANE is like any other AIR library (Flex library project) with one exception: it has to contain an instance of flash.external.ExtensionContext. It’s through this class that the ActionScript side of your ANE will communicate with the AIR C API.

The AIR C API

Think of the AIR C API as the layer that sits between your ActionScript code and the native code you’ll have to write. Being in C, rather than ActionScript, this layer is compiled into your native code and has the task of ‘translating’ ActionScript calls and data structures to C and vice-versa.

The native library

You will typically have to write your native library in C, C++ or Objective-C and compile it into an .a file. Xcode is the tool normally used for that. Your native library will include FlashRuntimeExtensions.h – a header file that comes with the AIR C API and provides the interface to it.

iOS native library

The ANE package

In order to be used as a native extension, your AIR and your native libraries need to be packed in an .ANE file. Adobe’s ADT command line tool does that for you. We will see how in Recipe for packaging an ANE.

iOS ANE structure

What else?

Over to you

What problems have you run into on iOS that require native extensions? Share in the comments below.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">