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
This post will show you how to package an AIR Native Extension (ANE) on the command line.
The bad news first: it’s a nuisance – a lot of file copying, renaming and deleting before you even get to run any command-line tools. Now the good news: all of this can be automated with a script – see the note at the end of this article.
Before you put the automated scripts to use, however, it’s good to see what they actually do. Let’s get started.
Ingredients
- 1 well-built AIR library in the form of a SWC
- 1 library.swf file, extracted from the SWC
- 1 extension descriptor – your-extension.xml
- depending on your platform: 1 platform options descriptor – your-ios-platformoptions.xml, if packaging for iOS
- 1 well-built native library in the form of an .A, a .JAR or a .DLL file
Preparation time
- around 10 minutes for manual packaging
- up to a minute if using scripts – scroll to the bottom of the post for more information
Serves
As many as you dare serve your ANE to.
Preparation method
1. Gather the ingredients:
1.a. Make a copy of your AIR library’s SWC file and rename its extension to .ZIP:
1.b. Unzip the .ZIP copy you just created. This will result in a folder with two files in it: catalog.xml and library.swf:
1.c. Keep your original .SWF file and library.swf and delete the .ZIP file and catalog.xml:
1.d. Create a folder in which you’ll package your ANE and copy the following files to it:
- your original AIR library’s .SWF file
- library.swf, which you extracted from the .ZIP archive
- your extension descriptor
- your platform options descriptor, if you’re packaging an iOS ANE
- your native library – an .A, .JAR or .DLL file
2. Open a Terminal (Mac OS) or a Command Line (Windows) window and run Adobe’s ADT tool:
You’ll need different options depending on which platform(s) your ANE supports. Below are four examples for packaging an ANE for:
iOS
adt -package
-target ane
path/where/you/want/YourANE.ane
YourExtensionDescriptor.xml
-swc YourAIRLibrary.swc
-platform iPhone-ARM
-C . .
-platformoptions YourPlatformOptionsDescriptor.xml
Android
adt -package
-target ane
path/where/you/want/YourANE.ane
YourExtensionDescriptor.xml
-swc YourAIRLibrary.swc
-platform Android-ARM
-C . .
Mac OS
adt -package
-target ane
path/where/you/want/YourANE.ane
YourExtensionDescriptor.xml
-swc YourAIRLibrary.swc
-platform MacOS-x86
library.swf
YourMacOSNativeLibrary.a
Windows
adt -package
-target ane
path/where/you/want/YourANE.ane
YourExtensionDescriptor.xml
-swc YourAIRLibrary.swc
-platform Windows-x86
library.swf
YourWindowsNativeLibrary.dll
Is that it?
Well, no. And it doesn’t have to be that painful either. This step can be automated together with the building of the native library and the AIR library, so you have a clean-built ANE in one step.
We are going to see how that’s done in the next article: Automatic ANE packaging.
So, which platforms did you try the command line for?
Pawan
hey,
i followed the steps but when i run the command i get error message:
error 102: Invalid namespace http.adobe.com/air/extension/3.1 or 3.7
searched everywhere but couldn’t find a solution.
please reply if you think of something that might help.
thank you.
Pawan
that error is gone but now i got a new one :p
error 105: extension.platforms.platform.applicationDeployment.finalizer contains an invalid value
Radoslava
Hi Pawan,
On error 102: did you have to change the namespace in any of your descriptor files? It would be great if you posted your solution for other people experiencing the same problem.
On error 105: could you give us details on how your ANE files are structured and which file you get the error reported in? Which platform(s) are you packaging for?
Cheers,
Radoslava
Ayman
On MacOS :
1 – What is the appropriate (.framework / .dylib / .a) native library ?
2- Are there any update to AIR SDK to build it on 64-bit ?
Date : 2017
Hristo
Hi Ayman,
On your questions:
To build an ANE on OSX you have to make an .a library inside the Xcode first.
The next step is to wrap it in Flash Builder as an ANE library.
About the 64-bits ANE: if you are using the latest AIR SDK any ANE you
compile should include 64-bit support by default. AIR SDK has 64-bits included
since version 16.
Out of curiosity: what kind of apps are you building?
Cheers,
Hristo