Problems with Unity app compilation
While development of our API.AI Unity SDK I have faced with upset thing. When trying to build sample Unity app for iOS platform build ends with error:
Cross compilation job ApiAiSDK.Unity.dll failed. UnityEngine.UnityException: Failed AOT cross compiler: /Applications/Unity/Unity.app/Contents/PlaybackEngines/iOSSupport/Tools/OSX/mono-xcompiler --aot=full,asmonly,nodebug,static,outfile="ApiAiSDK.Unity.dll.s" "ApiAiSDK.Unity.dll"
First I thought, that this situation is caused by external dll's, linked to the ApiAiSDK.Unity.dll library. Googling did not lead to anything useful...
So I tried to check my external libraries, and run
mono-xcompiler compiles .NET Assembly to the native iOS code.
It was intresting, that another libraries was compiled with
mono-xcompiler without problems, but ApiAiSDK.Unity.dll cause error:
Mono Ahead of Time compiler - compiling assembly ApiAiSDK.Unity.dll The class UnityEngine.AndroidJavaObject could not be loaded, used in UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null Missing method GetStatic in assembly ApiAiSDK.Unity.dll, type UnityEngine.AndroidJavaObject  93561 segmentation fault --aot=full,asmonly,nodebug,static,outfile="ApiAiSDK.Unity.dll.s"
So, you see, that problems with project compilation was caused by the Unity class
AndroidJavaObject, used for native Android interoperability. This classes should be placed in the code snippet like
#if UNITY_ANDROID // your code... #endif