Requirements
Prerequisite knowledge

Knowledge of developing AIR ANE
Knowledge of developing dynamic frameworks in Xcode
Required Adobe Products

Adobe Flash Builder (Download)
Adobe AIR Runtime (Download)
Required third-party products
 
Xcode (latest version) (Download)
User level

All
 

 
Introduction

Starting AIR 28, developers can use Swift based ANE for iOS/tvOS. Developers can also use iOS/tvOS based dynamic frameworks while packaging the application for respective iOS/tvOS platforms. Dynamic frameworks signing will be done while packaging the application.

 

Swift based ANE Support in AIR (iOS/tvOS)

There are some important modules which are necessary to create Swift based ANE. Below is the detailed description on how to create them individually.
 

Swift based dynamic framework (.framework)

This is a Swift module where AS developers write their own Swift based code for ANE as per the required functionalities. To create Swift based dynamic framework, follow the steps below:
 
1. Launch Xcode. Create new "Cocoa Touch Framework" project from "Framework & Library" section.
 
Choose a template for your project
 
2. Enter Project Name. Select language as Swift/Objective-C as appropriate.
Click Next to create the project.
 
Choose options for your new project
 
3. Write native swift code as per requirement. To Build your project, click "Product -> Build".
This will create a dynamic framework file on your disk.
 
Build project
 
4. Right click the created .framework file and click "Show in Finder" to locate your created dynamic framework file.
 
locate the created dynamic framework
 
5. You will find the below structure on your disk, after the dynamic framework file is successfully created.
 
structure on disk
 
6. Verify that the created dynamic framework executable is not signed. You can execute the below mentioned codesign command to verify the same.
Command:

codesign -d -v <dynamic_framework_executable_file>

Output:

<dynamic_framework_executable_file>: code object is not signed at all

 
Static library file (.a file)

This module creates Objective-C static library (.a) file to be used while ANE creation. Developers need to refer dynamic framework symbols to call dynamic framework functions inside static library.
 
1. Launch Xcode. Create new "Cocoa Touch Static Library" project from "Framework & Library" section.
 
Choose a template for your new project
 
2. Include the necessary header files e.g. FlashRuntimeExtension.h, SimpleNativeCAPISwift-Swift.h to be used in your static library project.
 
You can find framework header files in "Headers" folder inside .framework file.
For FlashRuntime header file, you can find in <AIR_SDK/include/FlashRuntimeExtensions.h>
 
Include the header files
 
3. Write Objective-C based code (This is same as previously developers used to write static libraries for ANE creation).
Build your project from "Product -> Build".
 
Build project
 
4. Right click on the created static library file and click "Show In Finder" to locate your static library file.
 
locate the static library file
 
For detailed information on creating ios static libraries, refer: http://www.adobe.com/devnet/air/articles/building-ane-ios-android-pt3.html

 
Package Swift based ANE (.ane)

This module creates Swift based ANE, that developers use in their ActionScript library project (iOS Only). To package Swift based ANE from the above created resources, follow the steps below:
 
1. Along with the existing necessary resources for ANE creation, AS developers need to include dynamic frameworks (relevant .framework files) during ANE creation command. The platform.xml needs to mention the dynamic frameworks as shown below.
 

<?xml version="1.0" encoding="utf-8" ?>
<platform xmlns="http://ns.adobe.com/air/extension/28.0">
<linkerOptions>
<option>-rpath @executable_path/Frameworks</option>
</linkerOptions>
<packagedDependencies>
<packagedDependency><dynamic_swift_framework_path></packagedDependency>
</packagedDependencies>
</platform>

 
AS developers need to mention relative path of their dynamic frameworks under <linker options>tag. This rpath (relative path) will be used during app packaging. It is also required to mention dynamic frameworks (relevant .framework files) under <packagedDependencies> tag. These dependencies will be used during ANE packaging.
 
2. Sample ANE packaging command with folder structure:
 
Command:

adt -package -target ane <ane_file> <extensionxml_file> -swc <swc_file> -platform iPhone-ARM -platformoptions <platformxml_file> -C iPhone-ARM/ . -platform appleTV-ARM -platformoptions <tvOS_platformxml_file> -C appleTV-ARM/ .

 
Folder structure:
ANE packaging folder structure
 
iPhone-ARM folder contains dynamic_swift_framework_file as mentioned in package dependencies in platform_xml, Objective C Static library (.a) built for iOS and library.swf file.
appleTV-ARM folder contains dynamic_swift_framework_file for tvOS as mentioned in package dependencies in tvOS_platform_xml, Objective C Static library (.a) built for tvOS and library.swf file.
 
3. Sample IPA Packaging command and folder structure:
Command:

adt -package -target <target> -provisioning-profile <path-to-profile> -storetype pkcs12 -keystore <path-to-certificate> -storepass <password> <ipa_file> <appxml_path> <swf_path> Frameworks -extdir extensions

 

Folder structure:
IPA packaging folder structure
 
Where the <dynamic_frameworks_and_Swift_Dependencies_path> folder, or subfolders inside it contain Swift frameworks and its dependencies as mentioned below. These Swift dylibs can be found at 
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos for iOS and /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvos for tvOS
 
<dynamic_swift_framework>
  • libswiftCore.dylib
  • libswiftCoreGraphics.dylib 
  • libswiftCoreImage.dylib
  • libswiftDarwin.dylib 
  • libswiftDispatch.dylib
  • libswiftFoundation.dylib
  • libswiftObjectiveC.dylib
  • libswiftQuartzCore.dylib
  • libswiftUIKit.dylib
 
For Xcode 9 and Swift 4 support, AS Developers need to add three more swift dependencies as below from iphoneos folder from Xcode.
 
  • libswiftCoreFoundation.dylib
  • libswiftMetal.dylib 
  • libswiftos.dylib

 
Where to go from here

From here, you can develop new Swift based ANE's for iOS and tvOS. To know more about building a native extension for iOS and Android, you can refer the article: Building a native extension for iOS and Android.