Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

optimization - stepping may behave oddly : iOS/Unity

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.

like image 577
Sharad Chauhan Avatar asked Jul 13 '17 11:07

Sharad Chauhan


2 Answers

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

like image 182
Rich Skorski Avatar answered Oct 11 '22 12:10

Rich Skorski


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

Other C Flags: -DRUNTIME_IL2CPP=1

like image 31
DiegoQ Avatar answered Oct 11 '22 12:10

DiegoQ