optimization - stepping may behave oddly : iOS/Unity - ios

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 :
I have tried googling this and found these links :
APPNAME was compiled with optimization - stepping may behave oddly; variables may not be available
'Project Name' was compiled with optimization - stepping may behave oddly; variables may not be available
Xcode target compiled with optimization
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.

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

I had the same issue and I solve it adding to Apple LLVM - Custom Compiler FLags:
Other C Flags: -DRUNTIME_IL2CPP=1

Related

Swift - Command failed due to signal: Segmentation fault: 11 when build in configuration Release

I'm trying to compile a project then the Xcode said that.
I hope to receive the answers for these concerns, here are the situation:
Xcode 8.3.2
Swift 3.0
All Frameworks are built via Carthage (Exclude Fabric & Crashlitics)
When I build in Debug configuration everything are ok, but when I change to configuration Release then the compile always failed.
I tried to change the Optimization Level to Fast, Single-File Optimization[-O] then the Xcode works well and I also can archive to ipa file.
I have some concerns, could you please review ?
+ How do I completely resolve this problem and keep the default Optimization Level value for configuration Release ?
+ If I change Optimization Level value to Fast, Single-File Optimization[-O], could I submit the binary file to App store review ? Does it violet Apple's tos ?
Thank you,
you can get this error when the compiler gets too confused about what's going on in your code. I noticed you have a number of what appear to be functions nested within functions. You might try commenting out some of that at a time to see if the error goes away. That way you can zero in on the problem area. You can't use breakpoints because it's a compile time error, not a run time error.
And it might be possible that you have used a custom frameworks so just remove that custom framework which shows error

Static Library works fine with debug,but does not with release

I have an iOS project which has a static library and in the library there is a encrypt method and in the method it refers a lot of system encrypt method about AES encryption. When I build the static library with release,it returned the correct data.But when I build with debug mode,it returns nil.
What's the differences between the two modes?
The same source code can build out different binary files that works differently?
Help me,thanks beforehand. This is where I choose the two modes.
The main difference is the level of compiler optimization. Select the project target and look at the Build Settings and compare Debug to Release.
One potential reason for the crash is that the code has some memory usage errors that by coincidence do not cause a crash with code optimization but do with no optimization. Or there are some other configuration difference. See the comment by #iDev.
A starting point is to fix all warnings, both compiler and Analyzer. The examine the crash log to understand the crash. If you need help with that add a crash report to your question.

Xcode LLVM 3.1 and GCC_OPTIMIZATION_LEVEL

I have an Xcode 4.3.2 iOS 5.1 project that compiles and runs fine when my build configuration uses a GCC_OPTIMIZATION_LEVEL of None [-O0], but fails with a EXC_BAD_ACCESS error when using any other optimization level. My project has GCC_VERSION set to Apple LLVM 3.1 (the default). Does this indicate a problem with my code?
Most often it indicates problem with your code. Like:
accessing already deallocated memory
reading or writing memory out of bounds of allocated array
using non initialized variables or class members
and many many others...
In rare cases it happens that such kind of crash turns out to be a compiler bug. But that is rare. More often that is problem with your code.
Try to pinpoint code that crashes and try to see how variables are used nearby that code. Check if everything is used/allocated/initialized/freed correctly there.

NEON assembly fail to build for iOS in Xcode 4.3.2

I have a code base which compiles fine in all other NEON compilers, ndk-build, RVDS, etc, but under Xcode I get the error "bad instruction" for every NEON instruction I call. It basically seems like NEON is not detected.
I am attempting to build a static library, I went to New Project, selected Cocoa Touch Static Library, then added my existing files.
Everything I'm reading indicates that NEON should be already enabled. I removed all references to armv6, and am targeting iOS 5.1
Also the code in question is all contained as routines defined in ".s" files -- pure assembly. I am not using the intrinsics method calls.
It seems like the compiler is barfing on the whole file...
Unknown pseudo-op: .cpu
It lists all of the other settings, like .fpu, etc
Here are my current settings:
(source: wasteonline.net)
(source: wasteonline.net)
(source: wasteonline.net)
After the as tool I mentioned in my last answer turned out to be choking on my syntax as well, I realized there must be something else going on.
I followed the guidelines on the bottom of this post http://www.shervinemami.info/armAssembly.html#template
The changes I needed to make were:
converted my instructions to all lower case
use the naming directives to be compatible with mach-o (solved linker problems)
Try to use GCC4.2. I solved a very similar problem switching to the old, good GCC.
In Build Settings -> Compiler for C/C++/Objective-C, select GCC
Actually, if you check the LLVM ARM status page, you'll see that it cannot yet parse .S files.

Cannot step into a particular function in a library in Xcode 4.2/iOS 5.0

I am working on an iPhone app in which I need to include a library (lib.a) for the app to work. This library (lib.a) consists of multiple files(classes). While debugging, I noticed that I could not step into any function in the file sync.m (included via lib.a), but I could step into any function in file (data.m) (also included via lib.a). I am wondering as to why I can step into one file and not another. I am using XCode4.2/iOS 5.0
I have checked all the debug settings in both my app and the library.
Generate Debug Symbols => yes (for debug)
I am also in the "run for debug mode".
The only thing that I suspect at this point is that I moved the sync.m from one folder to another ... Would that cause a problem with respect to the debug symbols ??? Where are the debug symbols stored? In the dsym file? Where can I find this file as I would like to see which debug symbols are being generated and which are not.
I would appreciate it if anyone can throw some light on this issue.
The object was not being retained and thus was pointing to nothing(NULL). Obviously, therefore function couldn't be stepped into.

Resources