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.
Related
Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change their look and turn to dotted blue outlined. Xcode does not stop execution at these breakpoints although code has been compiled, loaded and executed. I checked it in Console by adding some prints.
When I hover over breakpoint Xcode shows a message:
Xcode won't pause at this breakpoint because it has not been resolved
Resolving it requires that:
The line at the breakpoint is compiled.
The compiler generates debug information that is not stripped out (check the Build Settings).
The library for the breakpoint is loaded.
All trivial solutions like reloading, reapplying breakpoints have not helped.
Did anybody else see something like this? Is there a way to solve it?
Screenshot for reference:
Ok, so in my particular case rebooting laptop has helped. All breakpoints are now good. But it would still be nice to know the cause of the problem.
Make sure that the file in which you are adding breakpoint is having correct target set in target membership.
Click on .m file in which you want to add breakpoint.
Select the file inspector.
Check if you have selected correct target for that file or not (check below image).
What worked for me, was to select the files, delete them with - Delete>Move To Trash - and then drag the files back from the trash to the project.
In my case the issue was happening, because class was not added to the target, which I was trying to build.
For my case somehow the code path was never invoked and very likely considered as dead code. The same thing applies when not adding the file to the target that you want to debug.
This can be the case or somehow debugger might not be able to resolve your breakpoint. The first thing in this case should be cleaning derived data and any caches.
But instead of recloning your repo you can just delete breakpoint config from the location described in this answer
In Xcode 14 the problem is much more prevalent and "consistent". I figured out one pattern where it always fails and how to mitigate it.
If you have a final class then breakpoints set on or inside a private method will have that issue. If you remove private from the method or final from the class the breakpoints will get resolved properly.
If tried everything and nothing worked I suggest the following:
Reclone your repo
This is what worked for me.
I just passed through this problem and the solution for me was recreating the files.
Note: The ones I was trying to originally breakpoint on were copied from another project. When I created the new files, even though their Identity and Type looked just the same (target membership, encoding, paths), for some reason breakpoints started to work again.
Note 2: When copying and pasting code to your new files (if done manually), migrated breakpoints - created in the older file - will continue to fail. Only the ones created in this new file will work properly.
Hope it helps.
My case
Working on framework development. Framework is injected into the sample app for development/run purpose. Breakpoints inside the framework won't work.
Fix
Just removing xcframework in sample app and replacing with framework.
Reason
xcframework are precompiled outside of the app, so lib isn't compiled when project is built and that's why breakpoints doesn't work.
For me reboot the Xcode, and it works~
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.
I've set an "All Exceptions" exception breakpoint for my project. In Xcode 7, it mysteriously fires on launch in main.m, but there doesn't seem to be anything obviously wrong. On continuing, the app runs normally.
Even running the project in Xcode 6 now causes this breakpoint to fire.
I can't figure out what is causing this. The threads don't indicate anything specific to what the cause is.
Maybe it's some sort of font issue in the Storyboard or something? Does anyone know a fix?
NOTE: It's a C++ exception, not Objective-C. Perhaps due to missing fonts. Xcode throws an exception in Main() in iOS 8 with 'all exceptions' breakpoint
I have almost the identical problem in Xcode 7, as of beta 3. This workaround solved it for me.
Because it's a C++ exception, you can change your "All Exceptions" breakpoint to catch only Objective-C exceptions. Having done this, I no longer hit the mystery break on startup, and because I'm not writing C++, get 99% of the value of having the "All Exceptions" break point on.
Here's how:
Go to the breakpoints tab (View > Navigators > Show Breakpoint Navigator or ⌘7).
Right click on the All Exceptions breakpoint and "Edit Breakpoint..."
Change the Exceptions covered to Objective-C only.
I started seeing the same behaviour in my application using the shorthand dictionary initialisation #{ ...: ... } in the willFinishLaunchingWithOptions function.
The problem was solved by replacing it with dictionaryWithObjectsAndKeys instead. I'm not sure if this was specific to my case or if the compiler has some kind of a problem with the shorthand syntax, but it's worth checking out if you're using that syntax.
I have noticed that My Xcode generates "Thread 1: EXC_BAD_ACCESS(code=1, address0X0)"
when ever there is a break point at a value which is global.
like in my case I was accessing a variable in other class, which I declared in another class named Global class to declare my all global Var there. Now am accessing it in another class, it shows Thread 1: EXC_BAD_ACCESS(code=1, address0X0)
Due to this problem I am not able to debug things.
Please Help. Thanks
Somewhere somehow you are accessing a deallocated variable, usually Thread 1: EXC_BAD_ACCESS(code=1, address0X0) stand for that, what do you mean by global variables, is your global class containing them already defined?
I think what you are locking for, is Singleton, but maybe i`m wrong
Well After discussion with few people,
I checked the same breakpoints but for iOS7, in spite of iOS 6.1
And yes there were no issues related "Thread 1: EXC_BAD_ACCESS(code=1, address0X0)" anymore.
So If you are having same issue while debugging for ios6.1
you have to change the debugging scheme
Step.1 Click on Project(on the right side of Run, Stop button on the top of XCODE)
Step.2 Click on the Edit Scheme.
Step.3 Click on Debugger and change it to GDB from LLDB
That's it.
In case if you dont find GDB in step.3 , you may have to install it first
and then repeat the step.
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.