13
votes

I am trying to integrate unity to iOS application. I have followed this tutorial http://www.agnosticdev.com/blog-entry/swift/integrating-unity-and-vuforia-ios-swift-project

Now after integrating when i start my app it crashes and show this error on console : was compiled with optimization - stepping may behave oddly; variables may not be available.

Crash : Crash log

I have tried googling this and found these links :

  1. APPNAME was compiled with optimization - stepping may behave oddly; variables may not be available
  2. 'Project Name' was compiled with optimization - stepping may behave oddly; variables may not be available
  3. Xcode target compiled with optimization
  4. Xcode: Cannot set optimization level for debug

and nothing changed.

I have changed optimization level of both project and pod. I have also added this line to pod file : project 'MyProject', 'Debug - local'=>:debug, 'Debug - staging'=>:debug, 'Debug - PRODUCTION'=>:debug ( before target 'projectname' do)

Also I have unchecked Strip Engine Code in unity.

What can i do to overcome this error ? Any help would be appreciated, thanks.

2
It can very likely be because some number type variable is not initialized before being used. When optimization is enabled it will pick garbage value where as in other cases it may take 0. Try using zombies - developer.apple.com/library/content/documentation/… it might help in finding the exact code.Amresh
@AmreshKumar thanks i will look for zombies.Sharad Chauhan
@SharadChauhan I am running into the same issue. Have you found a solution yet?duong_dajgja
@duong_dajgja No, I never found one.Sharad Chauhan

2 Answers

2
votes

I had the same issue and I solve it adding to Apple LLVM - Custom Compiler FLags:

Other C Flags: -DRUNTIME_IL2CPP=1

1
votes

The code you're debugging is IL2CPP code, which is likely in a library prebuilt with optimizations (probably in libiPhone-lib.a). Your build settings only effect the code being compiled now in your xcode project, so they wouldn't effect a prebuilt lib. To get rid of the warning, you will need to rebuild that library, and you will need Unity source code to do that.

More importantly, it's not the cause of the crash. It's just telling you that it's going to be harder to find the source of the crash.

It looks like it's calling a function called LoadMetadataFile and crashing when accessing the return. You can probably set a breakpoint on that function call and see what's going in and out of it to find the next debugging step (the bl instructions 5 lines above the highlighted crashing line).

Here are some documents that might help you: Apples calling convention docs: https://developer.apple.com/library/content/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html

Arm instruction reference (opened to the crashing instruction): http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/LDRSW_imm.html