使用带有本机扩展的ant mxmlc任务

问题描述 投票:4回答:5

我有一个AIR应用程序,我正在编译移动。有一个iOS原生扩展(JamPot MobileBackup),在IDE中使用时编译得很好。

但是,IDE现在还不足以支持其他平台,我决定构建一个Ant脚本来运行构建过程。

问题是这个特定的ANE似乎在扩展代码中定义了MobileBackup类,而不是像我正在使用的其他ANE那样在单独的.as文件中定义。

这是我看到的错误:

[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;

mxmlc调用如下所示:

<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>

其中app.ane.path是项目的.ane文件集合的路径。

我也尝试过使用library-path而不是external-library-path。

除了添加build.xml之外,我根本没有改变Flash Builder项目的布局或内容,它仍然可以在IDE中编译。

我需要做什么才能在IDE之外进行编译?

flex air mxmlc
5个回答
4
投票

我把这一切都搞定了,并决定在发布之前再做一次尝试。我想通了,所以我会在这里发布其他人的结果。

Flash Builder必须将SWC从ANE中拉出来以供mxmlc使用。我在其他地方找到了SWC的副本,并将其添加到我的libs文件夹中,嘿presto,它的工作原理。


3
投票

我无法解释原因,但如果您复制并重命名.ane文件并将其更改为.swc文件(字面上复制和重命名,无转换),然后将ANE的目录作为外部库路径引用 - 它可以工作。

<compiler.external-library-path dir="${ANE_DIR}" includes="*.swc" append="true" />

1
投票

我查看了mxmlc Ant Task的源代码,它明确地忽略了任何不是* .swc的文件。我在github上分叉了apache / flex-sdk并修复了它,所以mxmlc接受* .swc和* .ane。您可以在https://github.com/leapingbytes/flex-sdk克隆固定版本(构建固定的ant任务jar,转到modules / antTasks并运行ant)。


1
投票

正如其他人发布的那样,mxmlc将忽略* .swc以外的任何文件扩展名进行链接。我通过将所有.ane文件复制到临时目录,命名为.swc然后调用mxmlc来解决这个问题:

<!-- Copy all ANE files to temp SWC files because mxmlc only accepts SWC for linkage -->
<copy todir="${basedir}/temp-swc" overwrite="true">
    <fileset dir="${basedir}/_extensions"/>
    <globmapper from="*.ane" to="*.swc"/>
</copy>

<mxmlc
    <!-- ... --> >

    <!-- ... -->

    <external-library-path dir="${basedir}/temp-swc" includes="*.swc" append="true"/>
</mxmlc>

<!-- Remove temporary SWC files after usage -->
<delete dir="${basedir}/temp-swc" />

0
投票

我直接使用java任务。

当我将一个文件的绝对路径附加到-library-path选项(别名-l)时,它可以工作。

但是,它无法在mxmlc任务中工作。

<java jar="${FLEX_HOME}/lib/mxmlc.jar" fork="true" failonerror="true" dir="${FLEX_HOME}/frameworks">
<arg value="-o=${basedir}/${swf.file}"/>
<arg value="-load-config=airmobile-config.xml"/>
<arg value="-l+=${basedir}/${LIB_DIR}"/>
<arg value="-l+=${basedir}/${ANE_DIR}/us.sanguo.ios.ane" />
<arg value="-debug=false"/>
<arg value="-optimize=false"/>
<arg value="${basedir}/${main.file}"/>
</java>
© www.soinside.com 2019 - 2024. All rights reserved.