xcode optimization level problems

Hi there,

I’m using Unity 5.2.1 and XCode Version 7.0.
I’m trying to deploy my App to the App Store (App is already deployed to Android Play Store without problems).

Becaue only 64Bit supported Apps are allowed I set preferences to Scripting Backend “IL2CPP” and Architecture set to Univeral. Why are those configurations not set by default? You can’t deploy otherweise, so this should be standard?

Then I create a Release Build and open this in Xcode, attach my iPad and press Play.

The app does not run, from afirst simple scene ih normally loads another scene, this doesn’t hapen. Also the touch is not recognized. But the App does work without problems when I do a Debug Build! The difference between those builds is the optimization level in Xcode.

When I set optimization level to none, the app runs - no matter if release or debug mode. When I set optimization level to “fast” (O1) the app has less problems but still some. I thinks it’s not ok to release the App to the store without code optimization?

The problem is I can’t debug the code optimized code. So I have no Idea which parts of my code seem to be problematic. Mostly the touch seems not to work, but I’m not sure. I reduced the code to a very simple touch handling, that worked. Also the music is not playing. But its not feasible, to step by step change code, then export and wait 5 Minutes to compile with code-optimization for checking if this change makes problems…

So my question is: Does nobody else run into such problems? What code does typically make problems with code optimization? Is there anything known that you should don’t use? For example I suspect that calling Invoke(“methodname”) call could make problems: Maybe the method to call is deleted with the optimizer because this method is never called directly? Where can I read something about what the code optimizer excactly does?

Are there possibilities to debug optimized code?

Shall I paste a simple code example that is problematic with optimization level “fastest,smallest” ?

Thanks for any hints,


After one day of struggling I can now answer myself:
It is possible to debug a code optimized build, just look in the debug output in xcode.

Problematic with code optimization was using Reflection!
I wrote a better Debug-Log Class with this method:

 public static void Log(object message)
            StackFrame frame = new StackFrame(1);
            var method = frame.GetMethod();
            var type = method.DeclaringType;
            var name = method.Name;
            Log(message, type, name);

 public static void Log(object message, Type type, string name)
            string mesgStr = type + " - " + name + " : " + message + "


if you call this method for example inside Awake() running with code optimization will produce null reference exceptions.