Developing ’Native Extensions for iOS’ requires knowledge of both native iOS code(C/C++/Objective C,XCode, static libraries etc) and AS code. Thus, for people who are comfortable only with one of the two, it may not be an easy transition, and might lead to some issues. The idea behind this page is to make this transition a little bit easier and list the commonly faced issues by Native Extension developers.
Points to Keep in Mind
1. extensionID
An extension is recognized by its extensionID. Thus, one should try to keep it as unique as possible, as an application developer might want to use more than 1 native extension in his application. Having the same name will create conflicts and the application won’t get packaged or work as expected.
a. Same extensionID should be used in the extension.xml, application.xml and the AS Class where ExtensionContext.createExtensionContext() function is called.
b. Using “nativeExtension” as the extensionID isn’t really a good idea. Prefixing the extensionID with com.developerName is probably the way to go.
c. Prefix all the resources used by the extension with the extensionID. When multiple native extensions are used, the resources of all the extensions are merged in the application directory. Any conflicts will cause packaging to fail.
2. SWC linking
The most common mistake made by application developers, while using native extensions in their app is to merge the SWC into application code.
a. If using Flash Builder or Flex Builder(<4.6) , make sure that when specifying SWC linkage in the packaging options, for all the native extension SWCs, you have selected Link Type:”External” and not “Merged Into Code”:
b. If using command line to compile your application, make sure that the compiler switch used for linking SWCs is -external-library-path, and not -library-path and path to SWC is provided to this parameter. Another common mistake is to provide the ANE path here, instead of the SWC path.
c. In Flash Builder 4.6, there is in-built support for linking ANEs, and one can just directly go to the Native Extensions tab and specify the path to ANEs there. Flash Builder will take care of the linking.
3. extension.xml
a. For AIR 3.0(native extensions for iOS not supported in AIR namespace <3.0), the extension descriptor namespace to use is 2.5, while for AIR 3.1, 3.2, 3.3, the extension namespace to use is 2.5/3.1. When using namespace 2.5, all the frameworks of iOS 4.3 SDK are linked by default. However, when using namespace 3.1, only these frameworks are linked by default:
|
|
|
|
If linking to any other framework/library, one needs to use the platformoptions flag of ADT, details of which are available here.
b. Make sure that the initializer and finalizer names in the extension descriptor map to actual function names being used in the native code. It is a good idea to prefix them with the extension ID, as multiple extensions cannot use the same initializer and finalizer names.
4. Errors and Warnings
a. When packaging an app using native extensions, sometimes you may encounter errors and warnings similar to the following:
ld warning: unexpected srelocation type 9
ld warning: unexpected srelocation type 9
… (repeating several times)
Undefined symbols:
“_vDSP_vsdiv”, referenced from: …
“_vDSP_vsmul”, referenced from: …
“_vDSP_sve”, referenced from: …
“_vDSP_vflt16″, referenced from: …
“_vDSP_create_fftsetup”, referenced from: …
“_vDSP_ctoz”, referenced from: …
“_vDSP_fft_zrip”, referenced from: …
“_vDSP_vmul”, referenced from: …
“_vDSP_zvmags”, referenced from: …
ld: symbol(s) not found
Compilation failed while executing : ld64
This is probably because the native extension is compiled with an iOS SDK greater than the one available in the AIR SDK(currently, 4.3). In this case, using -platformsdk <path to the latest iOS SDK> while packaging your application might resolve your issue.
b. Sometimes, it might so happen that when using Flash Builder, your IPA does not get compiled, however, there’s no real error you can see. It may be that the ld warnings take up the entire error screen and the actual errors are not visible. In that case, package the IPA using the ADT command-line to view the actual errors.
5. Exception Handling in native Code
Currently, exception handling in the native iOS code(Objective C/ C/ C++) does not work for iOS(might cause application to crash). So, for the time being, extension developers are advised not to use @try-@catch-@finally type of syntax in their extension.
6. Debugging Native Extensions
You may find details of this here
7.Creating high resolution applications for the new iPad
For this, one needs to have access to iOS SDK 5.1+. For more details, read this.
8. When and how to use Entitlements
Details can be found here
9. Using platformsdk switch for iOS on Windows
With AIR 3.3, it is possible to package an IPA using the platformsdk switch on Windows too. You may find the details here
Sample Native Extensions can be found here









