如何在部署到iPhone时禁用Xamarin IOS中的AOT

时间:2017-02-01 07:13:06

标签: xamarin xamarin.ios xamarin.forms

我的解决方案包含3个项目:

  1. 我的后端项目包含程序集My_Test_App(可移植)

  2. My_Test_App.Android

  3. My_Test_App.iOS

  4. 我使用VS2015开发并使用mac进行构建和部署。它在iOS模拟器中工作正常。我的iOS项目不使用链接器。我还没有检查LLVM和增量构建。

    但是当我尝试调试到iPhone设备时,我收到了这个错误:

    Severity    Code    Description Project File    Line    Suppression State
    Error       Could not AOT the assembly/Users/myMacName/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Release/mtouch-cache/64/Build/My_Test_App.dll'    My_Test_App.iOS 
    

    我的问题是:

    1. 如何在Xamarin.iOS项目中禁用AOT?当我检查iOS项目的csproj文件时,它在droid项目中没有。

    2. 是否正确禁用AOT解决方法?

    3. 感谢您的回答!

      我的构建日志:

       1>------ Build started: Project: My_Test_App.Droid, Configuration: Debug Any CPU ------
      2>------ Build started: Project: My_Test_App.iOS, Configuration: Debug iPhone ------
      1>  Consider app.config remapping of assembly "System.Runtime, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [] to Version "4.1.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.Runtime.dll] to solve conflict and get rid of warning.
      1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Runtime" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly></assemblyBinding>
      1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
      1>  My_Test_App.Droid -> D:\Project\2017\Xamarin Test\test-mobile\My Test App\My_Test_App.Droid\bin\Debug\My_Test_App.Droid.dll
      2>  Generated session id: c7eaf4168fcb1f8aaecd3a6cbb0f37ee
      2>  Generated build app name: My_Test_App.iOS
      2>  Connecting to Mac server MTMAC22s-Mac-mini.local...
      2>  No way to resolve conflict between "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
      2>  Consider app.config remapping of assembly "System.Numerics, Culture=neutral, PublicKeyToken=b77a5c561934e089" from Version "2.0.5.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\System.Numerics.dll] to Version "4.0.0.0" [C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll] to solve conflict and get rid of warning.
      2>  Consider app.config remapping of assembly "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.0.0" [] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\System.Net.Http.dll] to solve conflict and get rid of warning.
      2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
      2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
      2>D:\Project\2017\Xamarin Test\test-mobile\My Test App\My_Test_App.iOS\Renderers\CustomLabelRenderer.cs(143,53,143,69): warning CS0618: 'Label.Font' is obsolete: 'Please use the Font attributes which are on the class itself. Obsoleted in v1.3.0'
      2>  My_Test_App.iOS -> D:\Project\2017\Xamarin Test\test-mobile\My Test App\My_Test_App.iOS\bin\iPhone\Debug\My_Test_AppiOS.exe
      2>  Detected signing identity:
      2>    Code Signing Key: "iPhone Developer: myemail@mycompany.com (HDZY35YSCS)" (6E0C54049FD692EBF4A54BBD72889DC336388268)
      2>    Provisioning Profile: "iOS Team Provisioning Profile: com.yourcompany.MyTestApp" (8f408fd0-90e0-4031-92e8-a6a56530778a)
      2>    Bundle Id: com.yourcompany.MyTestApp
      2>    App Id: F8AZP5FC9H.com.yourcompany.MyTestApp
      2>  Mono Ahead of Time compiler - compiling assembly /Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build/System.Net.Primitives.dll
      2>  AOTID BE85C9F7-62C4-0559-D329-FA98D6ECDAF2
      2>  Code: 0(0%) Info: 0(0%) Ex Info: 0(0%) Unwind Info: 0(0%) Class Info: 7(2%) PLT: 1(0%) GOT Info: 236(71%) Offsets: 86(26%) GOT: 120
      2>  Compiled: 0/0 (100%), No GOT slots: 0 (100%), Direct calls: 0 (100%)
      2>  Output file: '/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/System.Net.Primitives.dll.arm64.s'.
      2>  Linking symbol: '_mono_aot_module_System_Net_Primitives_info'.
      2>  JIT time: 0 ms, Generation time: 0 ms, Assembly+Link time: 0 ms.
      2>  /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/external/mono/eglib/src/ghashtable.c:549: assertion 'hash != NULL' failed
      2>  Mono Ahead of Time compiler - compiling assembly /Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build/System.Xml.ReaderWriter.dll
      2>  AOTID 77D080C4-2116-2E71-9BA1-0FB994D16E87
      2>  Code: 0(0%) Info: 0(0%) Ex Info: 0(0%) Unwind Info: 0(0%) Class Info: 7(2%) PLT: 1(0%) GOT Info: 236(71%) Offsets: 86(26%) GOT: 120
      2>  Compiled: 0/0 (100%), No GOT slots: 0 (100%), Direct calls: 0 (100%)
      2>  Output file: '/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/System.Xml.ReaderWriter.dll.arm64.s'.
      2>  Linking symbol: '_mono_aot_module_System_Xml_ReaderWriter_info'.
      2>  JIT time: 0 ms, Generation time: 0 ms, Assembly+Link time: 0 ms.
      2>  /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/external/mono/eglib/src/ghashtable.c:549: assertion 'hash != NULL' failed
      2>  Mono Ahead of Time compiler - compiling assembly /Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build/My_Test_AppiOS.exe
      2>  AOTID 298562A7-A350-2A44-1D0B-2E4FC728F9D1
      2>  Code: 54748(65%) Info: 456(0%) Ex Info: 19951(23%) Unwind Info: 1136(1%) Class Info: 4700(5%) PLT: 190(0%) GOT Info: 2018(2%) Offsets: 626(0%) GOT: 2872
      2>  Compiled: 97/97 (100%), No GOT slots: 0 (0%), Direct calls: 15 (37%)
      2>  Output file: '/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/My_Test_AppiOS.exe.arm64.s'.
      2>  Linking symbol: '_mono_aot_module_My_Test_AppiOS_info'.
      2>  JIT time: 21 ms, Generation time: 25 ms, Assembly+Link time: 0 ms.
      2>  AOT Compilation exited with code 139, command:
      2>  MONO_PATH=/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/10.3.1.8/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt  --aot=mtriple=arm64-ios,data-outfile=/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/My_Test_App.arm64.aotdata,static,asmonly,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/My_Test_App.dll.arm64.s "/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build/My_Test_App.dll"
      2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(696,3): error : Could not AOT the assembly '/Users/mtmac22/Library/Caches/Xamarin/mtbs/builds/My_Test_App.iOS/c7eaf4168fcb1f8aaecd3a6cbb0f37ee/obj/iPhone/Debug/mtouch-cache/64/Build/My_Test_App.dll'
      2>    at Xamarin.Bundler.AOTTask.Build () [0x00117] in <e61e7c7e12a34f76bb60aae297cbc79c>:0 
      2>    at Xamarin.Bundler.BuildTask.Execute () [0x00000] in <e61e7c7e12a34f76bb60aae297cbc79c>:0 
      2>    at Xamarin.Bundler.BuildTasks.Execute (Xamarin.Bundler.BuildTask v) [0x00000] in <e61e7c7e12a34f76bb60aae297cbc79c>:0 
      2>    at System.Threading.Tasks.Parallel+<ForEachWorker>c__AnonStorey6`2[TSource,TLocal].<>m__0 (System.Int32 i) [0x00012] in <8f2c484307284b51944a1a13a14c0266>:0 
      2>    at System.Threading.Tasks.Parallel+<ForWorker>c__AnonStorey3`1[TLocal].<>m__1 () [0x000ed] in <8f2c484307284b51944a1a13a14c0266>:0 
      ========== Build: 1 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
      

1 个答案:

答案 0 :(得分:4)

  1. 你不能在iOS上禁用AOT,你的项目将无法正常工作,因为iDevices不允许JIT'ing
  2. 不幸的是没有。
  3. 我们需要一个更长的构建日志(将'-v -v -v'添加为'mtouch'参数),但它可能会发生,因为程序集太大了。您可能希望在iOS项目设置中启用“链接所有程序集”。

    有关其他参考资料,请参阅此处:https://forums.xamarin.com/discussion/457/error-could-not-aot-the-assembly-servicestack-text-monotouch-dll