- Home /
JIT compile error on iOS
Hi,
I have been using Unity pro (trial) and brought some code from a developer and it seemed to work ok when I built it on my iPhone/ipad. As soon as the trial ended and I am back on the basic unity package when I build and try and run the code through Xcode I get this error:
ExecutionEngineException: Attempting to JIT compile method 'System.Linq.Enumerable:Iterate (System.Collections.Generic.IEnumerable`1,int,System.Func`3)' while running with --aot-only.
at System.Linq.Enumerable.Max[MapLevel] (IEnumerable`1 source, System.Func`2 selector) [0x00000] in :0 at LevelsMap.LoadState () [0x00000] in :0 at LevelsMap.Start () [0x00000] in :0
(Filename: Line: -1)
I am quite new to Unity and have done some searching online to find a fix however I don't know enough about coding to fix this, can anyone help me?
Could it be a simple fix?
Thanks Clive
Answer by Graham-Dunnett · Oct 07, 2014 at 08:33 PM
Back in the day Apple did not allow applications to support scripting language - the only scripting that was supported was Javascript inside Mobile Safari. Since Mono implements a scripting language, it's not allowable on the iOS devices. So, to get Mono working, all script is converted into Arm assembler in the build process. This is the so-called ahead of time (AOT) compilation. Your error is a JIT (just in time) meaning Mono is attempting to create script dynamically and convert it into assembler on the device. This is not allowed. I've no idea what code you've purchased, but it sounds like it was never designed to be compiled ahead of time. (Typically this means the script code is using dynamic code generation techniques and doing reflection)
Answer by gamesmiths · Oct 08, 2014 at 05:38 AM
Thanks Graham, do you think this is something you could fix for me if I sent you the code? I know the code works on web and android devices, and it does work on iPad/iphone if I am not plugged into Xcode, but if I am in Xcode and running the code through my iPad it crashes, however a development build does not crash! I am unsure if Apple will let a development build through though! Please let me know if you can help, it would save me a LOT of trouble!!!
Thanks Clive
Answer by Visartech · Oct 15, 2014 at 11:07 AM
Really, some LINQ methods are not supported with Mono compiler on iOS and cause JIT-compile errors. In case if you would like to use LINQ methods on iOS in Unity, I would suggest you to look at LINQ to iOS.
It's a custom implementation of LINQ to Objects extension methods that works without JIT-compile errors on iOS.
Answer by Valerius666 · Dec 06, 2016 at 11:27 PM
For me worked to change Scripting Backend type in Player Settings from Mono2x to IL2CPP.