Skip to main content
周戈35_2
Inspiring
January 11, 2017
Answered

Is Adobe planning on support writing ANE with Swift?

  • January 11, 2017
  • 6 replies
  • 2296 views

Dear Adobe,

AIR is an awesome cross platform solution, I have already published a multi platform product using AIR technology, my product website is https://verylab.com/

Nowadays the hardwares of mobile devices are fairly high spec, even the cheap price devices can handle AIR applications pretty well, it's safe to say that the performance issue of AIR on modern mobile devices is no longer the case, which is great!

The way I see it, the only thing that holds me back is not able to write ANE with Swift. I googled the internet and found the problem is: Swift is a dynamic framework, and AIR ANE only supports static frameworks, so we have to write ANE with Objective-C.

The language grammar between Swift and ActionScript has many commons, which is easy for ActionScript developers to learn and write Swift codes. It's a HUGE let down that AIR ANE does not support Swift : (

Is there any way or any workaround for AIR ANE to support Swift?

If there is a way, is Adobe planning on support it?

Regards,

Ge Zhou

2017-01-11

This topic has been closed for replies.
Correct answer el111

Updated repo with latest code.

Now allows calls to FRE functions from Swift

The project contains a translation of FlashRuntimeExtensions to Swift. It is comprised of 2 parts.

  1. A static library which exposes methods to AIR and a thin ObjectiveC API layer to the Swift code.
  2. A dynamic Swift Framework which contains the main logic of the ANE.

To allow FRE functions to be called from within Swift, a protocol acting as a bridge back to Objective C was used.   

Example - Converting a FREObject into a String

var swiftString: String = ""

var len: UInt32 = 0

let status: FREResult = FREGetObjectAsUTF8(object: object, length: &len, value: &swiftString)

var airString: FREObject? = nil

let status: FREResult = FRENewObjectFromUTF8(length: UInt32(string.utf8.count), value: ret, object: &freObject)

Example - Converting a FREObject into a String the easy way, using ANEHelper.swift

let swiftString: String = aneHelper.getString(object: object)

let airString: FREObject? = aneHelper.getFREObject(string: swiftString)

trace(value: swiftString)

GitHub - tuarua/SwiftIOSANE: Example Air Native Extension written in Swift 3 for iOS 10

6 replies

周戈35_2
Inspiring
February 20, 2017
Legend
February 25, 2017

Updated GitHub with a tool written in AIR to package app, deploy and debug on device

el111Correct answer
Legend
March 5, 2017

Updated repo with latest code.

Now allows calls to FRE functions from Swift

The project contains a translation of FlashRuntimeExtensions to Swift. It is comprised of 2 parts.

  1. A static library which exposes methods to AIR and a thin ObjectiveC API layer to the Swift code.
  2. A dynamic Swift Framework which contains the main logic of the ANE.

To allow FRE functions to be called from within Swift, a protocol acting as a bridge back to Objective C was used.   

Example - Converting a FREObject into a String

var swiftString: String = ""

var len: UInt32 = 0

let status: FREResult = FREGetObjectAsUTF8(object: object, length: &len, value: &swiftString)

var airString: FREObject? = nil

let status: FREResult = FRENewObjectFromUTF8(length: UInt32(string.utf8.count), value: ret, object: &freObject)

Example - Converting a FREObject into a String the easy way, using ANEHelper.swift

let swiftString: String = aneHelper.getString(object: object)

let airString: FREObject? = aneHelper.getFREObject(string: swiftString)

trace(value: swiftString)

GitHub - tuarua/SwiftIOSANE: Example Air Native Extension written in Swift 3 for iOS 10

Participant
February 15, 2017

hope

Participant
February 15, 2017

Yes. That's great!!

yakilery4470593
Participant
January 17, 2017

hope

Inspiring
January 13, 2017

I simple hate Objetive-C. Swift on the other hand it's nice and easy for a AS3 developer.

周戈35_2
Inspiring
February 10, 2017

Yes, totally agreed!

Support writing ANE with Swift is a huge feature, we're sincerely hoping Adobe could take it into consideration.

vini1024
Participating Frequently
January 12, 2017

hope

Legend
January 13, 2017

Yes. This would be great. I've written a couple for OSX (where it is supported) and Swift is a lot nicer to use