Recently when working on an iOS app I was trying to debug a runtime error. Unfortunately with Xcode 4.2, the only error message you get on abnormal program termination is a generic sigabrt message from the main method. No stacktrace, no last line executed, no log. Needless to say, this isn’t very helpful when debugging.

Turns out, Xcode has a nice feature where you can enable a breakpoint that triggers whenever an exception is thrown. Thanks to StackOverflow for the tip, I was able to find the error and fix it.

While muttering under my breath about sane defaults, I decide to leave the breakpoint enabled. After all, why wouldn’t you want to break on an exception? The trick is that it’s any exception, thrown by any process. Testing out my application further, one of the Apple libraries throws an exception and immediately my application grinds to a halt, even though the exception is not in my code and does not seem to affect any functionality. It’d be nice to have an option to only break on local exceptions, but I didn’t dig into it any further since enabling and disabling the breakpoint is so easy.

So, long story short: sane defaults help to make everyone’s life easier and to get useful debugging done in Xcode, you may need to enable a special breakpoint.