Set a Breakpoint on Unhandled Exceptions in the Xcode Debugger
One of the most frustrating things in iOS development is when the Xcode debugger doesn’t break on unhandled exceptions. On most other platforms I’ve developed, the debugger always stops on exceptions you didn’t specifically catch in your code. For some reason, the Xcode debugger doesn’t. I suspect it’s really more of a GDB problem when debugging Obcjective-C than an Xcode issue. There is something you can do though.
By adding a couple of breakpoints, the debugger should stop when an unhandled exception is thrown. Start by going to the Run | Show | Breakpoints menu. First, create a symbolic breakpoint named “objc_exception_throw” in the Location “libobjc.A.dylib”. The symbolic breakpoint is important, otherwise, the debugger won’t catch anything.
Then, create a 2nd breakpoint called “-[NSException raise]” in the Location “CoreFoundation”. You should be all set! Run your app, and viola! If it throws an exception, you’ll be in the debugger with a nice, beautiful stack trace!
One final suggestion I’d make is to make them global breakpoints instead of project breakpoints. By doing that, they will be set for all your apps from the beginning, saving you tons of time and frustration.