Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ant mxmlc task with native extension

I have an AIR application that I'm compiling to mobile. There is an iOS native extension (JamPot MobileBackup) that compiles fine when used in the IDE.

However, the IDE isn't sufficient now that we're moving to support other platforms and I decided to build an Ant script to run the build process.

The issue is that this particular ANE appears to define the MobileBackup class in the extension code, and not in a separate .as file like the other ANEs that I'm using.

Here's the error I'm seeing:

[mxmlc] Loading configuration file /Users/anderson/src/flex/4.6.0/frameworks/airmobile-config.xml
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 35 Error: Type was not found or was not a compile-time constant: MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                         ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 54 Error: Call to a possibly undefined method MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                                            ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 54 Error: Call to a possibly undefined method MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                                            ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(21): col: 35 Error: Definition ie.jampot.nativeExtensions:MobileBackup could not be found.
[mxmlc] 
[mxmlc]     import ie.jampot.nativeExtensions.MobileBackup;

The mxmlc call looks like this:

<mxmlc 
   file="${app.main.class.file}" 
   output="${build.output.swf.file}" 
   locale="${LOCALE}" 
   static-rsls="false" 
   accessible="false" 
   configname="airmobile" 
   debug="${build.debug.mode}" 
   failonerror="true" 
   fork="true" 
   maxmemory="512m">
  <source-path path-element="${app.src.path}"/>
  <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs/*" />
  </compiler.library-path>
  <library-path file="${FLEX_HOME}/frameworks/locale/${LOCALE}" append="true"/>
  <library-path dir="${spicelib.lib.path}" includes="*.swc" append="true"/>
  <library-path dir="${parsley.lib.path}" includes="*.swc" append="true"/>
  <library-path dir="${app.lib.path}" includes="*.swc" append="true"/>
  <external-library-path file="${AIR_GLOBAL}" append="true"/>
  <external-library-path dir="${app.ane.path}" includes="*.ane" append="true"/>
  <define name="CONFIG::DESKTOP" value="${output.config.environment.desktop}"/>
  <define name="CONFIG::IOS" value="${output.config.environment.ios}"/>
  <define name="CONFIG::ANDROID" value="${output.config.environment.android}"/>
  <define name="CONFIG::PRODUCTION" value="${output.config.environment.production}"/>
  <define name="CONFIG::STAGING" value="${output.config.environment.staging}"/>
  <define name="CONFIG::LOCAL" value="${output.config.environment.local}"/>
</mxmlc>

where app.ane.path is the path to the collection of .ane files for the project.

I've also tried using library-path instead of external-library-path.

Other than adding a build.xml, I've not changed the layout or contents of the Flash Builder project at all, and it still compiles fine within the IDE.

What do I need to do to get this to compile outside of the IDE?

like image 952
Scott A Avatar asked Jan 16 '23 08:01

Scott A


2 Answers

I had this all typed up and decided to make one more attempt before posting. I figured it out so I'll post the results here for others.

Flash Builder must pull the SWCs out of ANEs for mxmlc's use. I found a copy of the SWC elsewhere and added it to my libs folder and hey presto, it works.

like image 147
Scott A Avatar answered Mar 28 '23 04:03

Scott A


I can't explain why, but if you copy and rename your .ane file and change them to .swc files (literally copy and rename, no conversion) and then reference the ANE's directory as an external library path -- it works.

<compiler.external-library-path dir="${ANE_DIR}" includes="*.swc" append="true" />
like image 33
Jonny Avatar answered Mar 28 '23 04:03

Jonny