• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Swift iOS ANE Framework

Participant ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

Hey,

Has anybody played with making an iOS ANE using swift?

When using Swift, you can't make a Static Library (.a file). You have to make a framework instead. So in the extension.xml, instead of pointing to a .a file, I'm going to point to the .framework instead.

I'm about to finish up packaging up the ANE to see if this works or not. If anybody have experience in this, share you experience. Thanks.

TOPICS
Development

Views

6.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

it's impossible because AIR developed not using swift

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

I haven't made an ANE with swift but I HAVE made an ANE with a custom .framework.

Once you've made your .framework (ours was made with Obj-c but Swift should work as well, assuming both languages output the same format of .framework), you make ANOTHER project, which is where you make a .a file.  In the second project, you reference and use the .framework as necessary, and also put all your ANE interface code.  The .a gets included into the ANE like normal.  It must be a static library.

You also have to add the .framework as a <packagedDependency> in your platform.xml file, and if your .framework includes any resources, copy them into the iPhone-ARM directory when you build the ANE.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

‌yeah. I was wondering if I can skip the static library altogether .a file and just use the framework. If not, I guess I would have to build a static library in objective c that calls the swift framework.

I'm hoping it would work  since they're both libraries Of sorts.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

I don't know of any way of creating an ANE using anything other than a static, .a library as the interface between AS3 and Obj-C.  I originally tried to use a dynamic library and that didn't work either.

Of course, just cuz I haven't gotten it to work, doesn't mean it can't be done.........

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

‌I'm thinking as long as I have the flashruntimeextension api written in the swift framework, it'll work as the bridge to as3. Well, I'll see if it works in a day or 2.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

I'm not sure, because the bridge to AS3 is in pure C, not even Obj-C. Let

me know how it works!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

‌yyes, I imported the c API into the swift framework.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 27, 2015 Aug 27, 2015

Copy link to clipboard

Copied

oh cool! Well, I'll be interested to see if it works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 29, 2015 Aug 29, 2015

Copy link to clipboard

Copied

So I put the framework in the <nativeLibrary> in extension.xml, and ADT didn't know what to do with the framework. So I build a nib/empty static Library(.a) that imports the framework. That ANE was successfully built. I don't know if that'll work or not. We'll see. If you have another ideas, please share.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 29, 2015 Aug 29, 2015

Copy link to clipboard

Copied

Main point here is "Will this work or not" because ANE it's just a ZIP and you can put there your photo, for example

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 31, 2015 Aug 31, 2015

Copy link to clipboard

Copied

any news on this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 03, 2015 Sep 03, 2015

Copy link to clipboard

Copied

I can't build the ANE. It's not like a zip when you can zip the necessary files and changing the .zip to .ane. Flash Builder knows this isn't an ane file.

Ok, so here's the set up and I keep getting this error

Missing native library implementation 'myFrame.framework' for platform: iPhone-ARM

File structure.

/DatePickerANE.swc

/extension.xml

/platform.xml

/ios/library.swf

      /myFrame.framework

extension.xml

<extension xmlns="http://ns.adobe.com/air/extension/18.0">

    <id>com.minh.truong.datepicker</id>

    <versionNumber>1.0</versionNumber>

    <platforms>

        <platform name="iPhone-ARM">

            <applicationDeployment>

                <nativeLibrary>myFrame.framework</nativeLibrary>

                <initializer>DatePickerExtensionInitializer</initializer>

            </applicationDeployment>

        </platform>

    </platforms>

</extension>

platform.xml

<platform xmlns="http://ns.adobe.com/air/extension/18.0">

    <description>Date Picker ANE</description>

    <copyright>2015</copyright>

    <sdkVersion>9.0</sdkVersion>

    <linkerOptions>

        <option>-ios_version_min 9.0</option>

        <option>-rpath @executable_path/Frameworks</option>

    </linkerOptions>

    <packagedDependencies>

        <packagedDependency>ios/myFrame.framework</packagedDependency>

    </packagedDependencies>

</platform>


ADT package

adt -package -target ane datePickerANE.ane extension.xml -swc DatePickerANE.swc -platform iPhone-ARM -platformoptions platform.xml -C ios .


I've tried it with the platform.xml and without but same result.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 03, 2015 Sep 03, 2015

Copy link to clipboard

Copied

I was able to make a custom ANE with an obj-c framework, not swift, but it should be similar..... hopefully

Posting this in case it helps.

Here's a build script that I run to build the ANE after building my .a and SWCs.  I have to copy any assets from the .framework manually, and the directory HAS to be named iPhone-ARM.

#clear out iphone-arm folder

rm -fR iPhone-ARM/*

# copy swc to build folder

cp ../as3/MyANEAS3Lib/bin/MyANEAS3Lib.swc .

# extract main library.swf, copy to ios folder

cp MyANEAS3Lib.swc tmp.zip

unzip tmp.zip

rm catalog.xml

rm tmp.zip

mv library.swf iPhone-ARM

# copy .a to ios folder

cp ../ios/Build/Products/Release-iphoneos/libMyANE.a iPhone-ARM

# copy framework to build folder

rm -fR MyObjCFramework.framework

cp -R ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework .

# copy ios framework assets to ios folder

# add or remove lines here as needed - we have a bunch of asset files, a storyboard, etc

cp ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework/*.png iPhone-ARM/

cp ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework/*.wav iPhone-ARM/

cp ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework/*.ttf iPhone-ARM/

cp ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework/*.xml iPhone-ARM/

cp -R ../ios/Build/Products/Release-iphoneos/MyObjCFramework.framework/MyStoryboard.storyboardc iPhone-ARM/

# extract default library.swf, copy to default folder

cp ../default/MyANEDefaultLib/bin/MyANEDefaultLib.swc ./tmp.zip

unzip tmp.zip

rm catalog.xml

rm tmp.zip

mv library.swf default

# compile ANE

adt -package -target ane MyANE.ane extension.xml -swc MyANEAS3Lib.swc \

  -platform iPhone-ARM -platformoptions platform-ios.xml MyObjCFramework.framework -C iPhone-ARM/ . \

  -platform default -C default/ .

And here's the platform-ios.xml file. it includes my .framework and a couple of  frameworks I need and a .dylib I use.

<platform xmlns="http://ns.adobe.com/air/extension/16.0">

    <description>My ANE with a custom framework</description>

    <copyright>2015</copyright>

    <sdkVersion>8.1</sdkVersion>

    <linkerOptions>

        <option>-ios_version_min 6.1</option>

        <option>-framework CoreData</option>

        <option>-framework StoreKit</option>

        <option>-weak_library /usr/lib/libsqlite3.dylib</option>

    </linkerOptions>

    <packagedDependencies>

        <packagedDependency>MyOBJCFramework.framework</packagedDependency>

    </packagedDependencies>

</platform>

And here's the extension.xml:

<extension xmlns="http://ns.adobe.com/air/extension/16.0">

  <id>com.luckykatworld.LKWAuthentication</id>

  <versionNumber>0.0.2</versionNumber>

  <platforms>

  <platform name="iPhone-ARM">

  <applicationDeployment>

  <nativeLibrary>libMyANE.a</nativeLibrary>

  <initializer>MyInitializer</initializer>

  <finalizer>MyFinalizer</finalizer>

  </applicationDeployment>

  </platform>

  <platform name="default">

  <applicationDeployment/>

  </platform>

  </platforms>

</extension>

Hope that helps!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 08, 2015 Sep 08, 2015

Copy link to clipboard

Copied

I got the ANE to build but when I go to run the APP, I keep getting packaging error from Flash Builder.

ld: embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/myFrame.framework/myFrame) for architecture arm64 ld: embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/myFrame.framework/myFrame) for architecture armv7 Compilation failed while executing : ld64

I've built everything for iOS 9 but I keep getting this. What is this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 10, 2015 Sep 10, 2015

Copy link to clipboard

Copied

I just realized AIR 18 doesn't compile for iOS 9. I was going to update to AIR 19 beta but saw the bug that it doesn't compile iOS 9. Not sure if it's fixed or not. So I did a custom launch with the -platformsdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk

That error is gone but got a new one

ld: library not found for -lSystem.B

ld: library not found for -lgcc_s.1

Compilation failed while executing : ld64

Oh, well, this project will be on the sideline until AIR 19 comes out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 05, 2017 Feb 05, 2017

Copy link to clipboard

Copied

Looks like with the new AIR 25 beta, AIR is using iOS 10 SDK and will support Swift in an ANE.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 05, 2017 Feb 05, 2017

Copy link to clipboard

Copied

Correct me if I was wrong, but Swift libs can be used in Swift-only project. You can't use Swift in Objective-C/C++ projects? But you can use Obj-C in Swift.

AIR was done not in Swift.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 05, 2017 Feb 05, 2017

Copy link to clipboard

Copied

Correct me if I was wrong, but Swift libs can be used in Swift-only project. You can't use Swift in Objective-C/C++ projects?

You can call Swift from Objective C projects and call Objective C from C++ projects. If you are feeling crazy you can even combine all 3.

I've done it on OSX projects.

I did some more playing around today with AIR25 beta. I am able to call Swift code from an ANE.

You can build the Swift code into a dynamic framework and reference that from the static lib that is your main ANE.

However, and to my disappointment, I couldn't reference any "FRE" code in my Swift code 

So passing FREObjects, calling FREDispatchStatusEventAsync etc.

ANEs on iOS are different to OSX in that I believe all the ANE FlashRuntime code gets cross compiled into the main app. I could find no way of referencing the FRE code from the Dynamic Framework.

So it might be somewhat useful, but a large chunk of your ANE code would be Objective C.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 19, 2017 Feb 19, 2017

Copy link to clipboard

Copied

I have been able to build an iOS ANE which mixes ObjectiveC and Swift in the Simulator.

https://github.com/tuarua/SwiftIOSANE

When releasing, the package is created and successfully deployed to device.

However it crashes when run with either these errors:

code signing blocked mmap()

required code signature missing for '/private/var/containers/Bundle/Application/86FFE565-CBC9-4B19-A41F-169C8E98630C/Main_Swift.app/SwiftIOSANE_FW.framework/SwiftIOSANE_FW'

This is due I believe to the Swift Framework needing to be signed as part of packaging process.

I am not able to find a suitable way to do this without resigning the whole pacakge. If you are familiar with such problems please give me a shout.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 20, 2017 Feb 20, 2017

Copy link to clipboard

Copied

professorM​

周戈​

chris.campbell​

I was able to get the app running and working on my iPad.
It does need some bash scripts to do it but this to me is acceptable.


Process is
1) Sign the Dynamic Framework
2) Package AIR App
3) Resign AIR App
4) Deploy to Device via iTunes/Xcode/Terminal and optionally debug with fdb

I will push the scripts I have to github later.

It would be useful if Adobe could add something to adt which could incorporate Step 1 and 3

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 20, 2017 Feb 20, 2017

Copy link to clipboard

Copied

Thank you el111 

Finally, someone like you came along and changes everything!

I did some more playing around today with AIR25 beta. I am able to call Swift code from an ANE.

You can build the Swift code into a dynamic framework and reference that from the static lib that is your main ANE.

However, and to my disappointment, I couldn't reference any "FRE" code in my Swift code 

So passing FREObjects, calling FREDispatchStatusEventAsync etc.

Earlier you mentioned you can't reference any "FRE" code in your Swift code, have you solved this problem now? Or does it have to get Adobe AIR Team to solve it?

Dear Adobe, please add Swift support to the ANE, it will be a HUGE STEP UP!

Thanks again to el111​, you are awesome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 20, 2017 Feb 20, 2017

Copy link to clipboard

Copied

Earlier you mentioned you can't reference any "FRE" code in your Swift code, have you solved this problem now?

No. This would need Adobe to allow that, and it may mean a big change on their part or even Apple's part.

However, what the sample ANE hopefully exhibits is that it may not be a big deal.

  • The entry ObjectiveC file takes your FRE args and converts to native Objects and these are passed in to your Swift methods.
  • The provided aneHelper class provided can be used to automatically convert Objects received from Swift into FREObjects.
  • You can dispatchEvents back to AIR straight from Swift.

Think of the ObjectiveC file as an API layer to your main app logic in Swift.

So Swift is supported in ANEs just not how you imagined.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 25, 2017 Feb 25, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 02, 2017 Mar 02, 2017

Copy link to clipboard

Copied

Earlier you mentioned you can't reference any "FRE" code in your Swift code, have you solved this problem now?

No. This would need Adobe to allow that, and it may mean a big change on their part or even Apple's part.

I've actually figured out how to do this, to call FRE functions from within Swift

I'm working through it and will update the GitHub repo when it's ready

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines