During debugging I have seen seen TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION thousands of times which resulted in me wasting all kinds of time stepping through my code or putting in hundreds of NSLog statements to figure out where in my code the “uncaught exceptions” are happening.
From my work on other platforms, their debug environments did a much better job at showing where the exception is being thrown.
I finally did some research and found the answer.
It tells you nothing about where your app is crashing.
What you need to do is a add an objc_exception_throw breakpoint to your global breakpoints.
In Xcode go to Run > Show > Breakpoints menu.
Then Double-Click for Symbol.
Paste in objc_exception_throw
It will look like this:
Now run your program again in Debug mode (cmd-Y) and you will see this…
And you can quickly track down where your app is crashing.
The is supposed to be a way to edit the ~/.gdbinit file and put a “b objc_excpetion_throw” command into it so you don’t have to add it yourself, but I’m still trying to figure out how to make that work.*
*A solution to Global Breakpoint from Lou Krieg: ”I discovered that if you set that breakpoint as your blog says, then in the Groups & Files browser, expand Breakpoints, and drag that breakpoint from Project Breakpoints to Global Breakpoints a copy is made, and it seems to stick across projects”