I am using Xcode 9.3. I was using Xcode 9.2.
In 9.2, when an exception occurred, the debugger showed the line that caused the exception in the editor area, and I would see the variables and their values, plus the console in the debug area.
I did not change anything, and yet, now, I get the stack trace in the editor area. Given that the error is a simple "found nil when unwrapping a variable" and is an explicit error in a single line of code, the stack trace is next to useless in finding this. In fact, in looking at the stack trace and variables, the only variable that is nil is not a variable that is created within the method that the stack highlights.
Since then, I have enabled Zombies. I have had to re-add an All Exceptions break point (why does it forget these between versions is a whole other question) set to "on Throw".
I have deleted Derived Data, cleans the build, restarted Xcode, restarted the Mac and made various rude gestures to my screen. The last helped a bit, however the rest achieved nothing.
Any further suggestions?
Related
I updated to Xcode 8.3.3 and updated my OS, a bunch of pods, and so on. Now when I crash on unexpectedly found nil it takes me to a stack trace with it stopped on 'exc_breakpoint' (see screen shot). I have no breakpoints set.
I can't effectively troubleshoot these 'nil' errors because I don't know where they're occurring in my project (I can do it slowly by using a back trace and trying to sort through the messages, but this is way slower than if it just landed me on the right line like it used to do.)
Do I have some setting turned on by accident? Is this a bug? How can I get Xcode to go straight to the line of the nil crash?
Thanks!
Yes, I'm also faced this issues in my project. I just used to solve this by setting breakpoint in my code and I run manually line by line. Finally it will shows the nil value passing line.
If I faced crash issue while clicking any action button i will set breakpoint and run it line by line.
else if I faced crash issue while page loading. I will set breakpoint in viewdidload & viewdidappear
else I will set breakpoint in functions.
or try to use exception breakpoint
Through this above method I will solve crash issue in my project.
When I debug a project or when a project broke down, the Xcode console often put out some information about objects' memory address.Is there any way to figure out which instance the address is referring to and to locate related code lines?
Add a break point for all exceptions. That should do what you might really want in most cases:
It used to work fine but now I get this message when loading a certain scene and then the APP crashes.
2012-12-01 18:33:55.104 AppName[9561:707] cocos2d: CCSpriteFrameCache: Trying to use file 'art1-hd.png' as texture
I have no idea on where to start debugging this. Is there a way to get a more precise error message to understand why this happens?
Btw, I have changed my code signing identity to developer and XCode doesn't yet give me any trace of it on the console other than the plain message above. I checked as well the device logs on the Xcode-Organizer section but no trace.
I whish there was something like in Java + Eclipse, where I could get a precise STACKTRACE of where the crash happened.
Any suggestion on how to get a precise stacktrace (E.g. with function name generating the crash)?
PS: I have set strip debug symbols to "NO" in DEBUG, and to "YES" in Release, but I am builing on my own test iPod and hence I think it is automatically build for "Debug" (the section says build for running and testing which is confusing as the project settings allows only debug and release). But I think the problem is not here.. but in the issues above before the PS:
EDIT: If I look into the debug navigator I don't see any stacktrace of methods, as I want, but just threads.. I need to figure out how to use the global exceptions.
I have no idea on where to start debugging this.
You have the cocos2d source code. I would start there.
Search for "trying to use file" in CCSpriteFrameCache to understand what the cause of this message is (which I agree is confusing, why shouldn't you use that file?).
As for the stack trace, it's available as soon as you add a global exception breakpoint. If the breakpoint triggers in OpenAL code make sure to set it to catch only Objective-C exceptions.
Since I've upgraded from xcode 3.1 to xcode 4.2, when I debug a program and for some reason I get a SIGABRT error (i.e. calling a method of an object that doesn't exist) Xcode shows the error in the main function of the program, instead of the line that is generating the SIGABRT.
Maybe I'm missing some kind of configuration in the debugger or in xcode? any ideas?
I had the same problem for a long time and I found a solution just now. Don't know if it's the most kosher way, but at least it works for me. Basically you should create a global breakpoint (global meaning applying to all your projects).
Check out this blog post, and this tutorial on how to create symbolic breakpoints. I myself created an Exception breakpoint (it catches objc_exception_throw too) this way:
and then moved it to "User" breakpoints space:
Make sure that the scheme you are using has breakpoints active. You can turn them on by hitting the button next to the scheme selector.
http://bit.ly/zuTnpF
What did it for me, was something that I found here that has to do with creating NSZombies
I'll at least copy the highlights:
Go to your project in Xcode 4
Environment variables can be set up in the Scheme editor (find Product -> Edit scheme… in menu bar):
Name the variable as NSZombieEnabled and set its value to YES.
Run your app in Debug mode. You likely get a … message sent
to deallocated instance… message and the debugger stops at the line in error. This information leads to the problem.
When ready, disable NSZombieEnabled by changing YES to NO.
When I crash (for reasons I understand; that's not the problem) when I try to do something Cocoa isn't okay with, such as calling a method that doesn't exist or attempting to insert nil into a set, the debugger shows the stack from main() to __pthread_kill, without any of the frames that were present when the actual crashing code ran. There is a frame (9th from main) called objc_exception_rethrow. This leads me to believe that Cocoa Touch is trying to do something or other to recover all exceptions and die gracefully or something. However, it is very irritating when debugging to not have the ability to actually use Xcode4's debugging tools to investigate the calling stack frames, or even see where in my code I crashed.
Is there some way to make the objc_exception_rethrow behavior not happen, and just crash as soon as an exception is raised? Perhaps there's a debug setting that makes it crash earlier (at the right time)? (I haven't messed with any of the build settings in this project yet.)
I don't know any Xcode setting that could disable re-throwing exceptions. To my knowledge they are re-thrown by the runtime. You could try running the app without the debugger attached and let it crash. The crash report should contain a section "Last Exception Backtrace" which will give you exactly what you need in this case.
I found the answer: set a breakpoint on Obj-C Exceptions. It will go to the debugger when objc_exception_throw is hit, which is good. Unfortunately, this happens before the exception is printed, but we can make that happen anyway (most of the time) by setting the breakpoint's action to be (Debugger Action) po *(id *)($ebp + 8).