Cross compilation job Assembly-CSharp.dll failed. When building iOS.

Hi everyone, i’m having some problems building to iOS even though my project builds to android perfectly fine.

UNITY 5.0.0f4 free


Here is the error message i’m receiving when trying to build:

Cross compilation job Assembly-CSharp.dll failed.
UnityEngine.UnityException: Failed AOT cross compiler: /Applications/Unity/Unity.app/Contents/PlaybackEngines/iossupport/Tools/OSX/mono-xcompiler-wrapper.sh --aot=full,asmonly,nodebug,static,outfile=“Assembly-CSharp.dll.s” “Assembly-CSharp.dll” current dir : /Users/NAME/Desktop/New Unity Project/Temp/StagingArea/Data/Managed
result file exists: False. Timed out: False

stdout:
Mono Ahead of Time compiler - compiling assembly /Users/NAME/Desktop/New Unity Project/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll

  • Assertion at mini-arm.c:4771, condition `cfg->code_len < cfg->code_size’ not met

stderr:

at UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile) [0x000df] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs:113
at UnityEditor.MonoCrossCompile.CrossCompileAOT (BuildTarget target, System.String crossCompilerAbsolutePath, System.String assembliesAbsoluteDirectory, CrossCompileOptions crossCompileOptions, System.String input, System.String output, System.String additionalOptions) [0x0033c] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/MonoCrossCompile.cs:318
at UnityEditor.MonoCrossCompile+JobCompileAOT.ThreadPoolCallback (System.Object threadContext) [0x00000] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/MonoCrossCompile.cs:52
UnityEditor.HostView:OnGUI()


I have absolutely no idea what any of this means so if someone could help a simpleton to understand it, that would be great.

After searching online I came to the conclusion that this means there is an issue with one of my scripts. So i created a new project only importing scripts which i have written, leaving out everything else and the problem is still there. (Confirming my conclusion)

I have no compiler errors or warnings (pre building) so i was wondering if anybody knew a way that i could find out exactly which script is causing the issue.

It’s a large project and many of the scripts depend on each other, making simply deleting each one and rebuilding quite an undertaking. However if there is no other way i suppose it’s the only option.

Thanks in advance for any help!

I had the same problem. Managed to fix it by changing Scripting Backend option to IL2CCP (Mono2x caused problems).

Edit → Project Settings → Player → Other Settings/Configuration

After a couple of days i have solved this problem for me via this method.

I guessed that it was caused by the project being upgraded from unity 4.6 to unity 5 and this process had messed up one of my scripts somehow.

  • Created an empty project and imported my scripts only. Tried to build and make sure this issue was not caused by a plugin or something. Make sure you copy your scripts into the new project, don’t directly edit them because you will need to delete them and parts of them to figure out what is wrong. Keep a backup of your project in it’s entirety!

  • Delete a script fixing any errors created by just commenting out references etc.

  • Build the project and see if the AOT error still exists.

  • Repeat above until the project builds.

  • Make a new project and import all scripts again.

  • Delete just the last script you did when the project built (fixing any errors the same way as before).

  • Try and build again, it should be successful so you know this issue is with this particular script. Or a reference to it which you have commented out (to fix errors) in another script.

  • Make a new project and import all scripts again.

  • Go into the problem script and into the first function and comment everything inside it out.

  • Try and build the project.

  • Repeat this for all functions in the script until the project builds.

  • If the project does not build you will have to check any scripts that needed to be commented out previously. (This was not my issue so I have no advice here, you can still probably adapt this method)

  • When the project builds after commenting out a function, un-comment each previous one and build.

  • If the project builds each time until you have just that 1 function left, you know that this one is the issue. (It’s probably possible to have more than 1 problematic function, in this case you should leave them commented and use the next step on each problematic function).

  • Once you have 1 or more functions which fail the build, go through each one un-commenting a line in the function and building.

  • If the project builds, leave it un-commented. However if not leave it commented.

  • Do this until you are left with a few lines of code commented and a project that builds.

  • Now you have to figure out why these lines of code are causing your project to fail.

It’s very possible that there is actually no issue with the code commented out. In my case i had 1 line of code which was the problem. It took a struct from an array and called a function in another script. I had done this 7 times above in exactly the same way, yet each of these lines would build successfully.

I can say with 100% certainty that there was nothing wrong with that line at all, the only way i managed to get the project to build was to change.

SomeFunction(MyArray[MyArray.Length -1]);

to

int arrayPos = Array.Length -1;
SomeFunction(Array[arrayPos]);

This is pseudo code, not the actual code from my project, just to simplify the example.

As you can see, how there was an issue i do not know my guess is that when i converted the project from unity 4.6 to unity 5 it somehow bugged out and decided that this line of code didn’t make sense.

All in all it was pretty much a complete waste of time for something that really didn’t need fixing.

I hope this helps someone.