Stupid Xcode Tricks: Exception Breakpoint

Some of Apple’s classes like to throw exceptions, log a message to the console, and then crash your app, taking your stack trace with it.

Needless to say, this makes debugging extremely difficult, since you can’t inspect memory or even see who called what to cause the crash.

Thankfully, you can fix this! Here’s how:

  • Open the Breakpoint Inspector (Cmd-6).
  • Click the little + button in the lower-left corner.
  • Choose Add Exception Breakpoint…
  • Leave the defaults alone, and click Done.

Now whenever your app causes an exception, you’re dropped into the debugger, with a full trace, and access to all of your in-memory objects. Yay!

Thanks to Sean on Stack Overflow – though I also heard this in class once or twice and failed to implement it. (Whoops!)

Be First to Comment

Post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.