DEV Community

Jen Chang
Jen Chang

Posted on • Originally published at Medium on

Advanced Debugging Trick

Debugging all those crash issues in Xcode is not always fun especially when you don’t receive very useful information in the console log. To help ourselves better, the trick is to enable the Exception Breakpoint. This can be found on the + located on the left hand bottom corner of Xcode.

Exception Breakpoint

Enable the Exception Breakpoint to break on all Objective-C exceptions. This is sufficient to catch all the ones from the Apple Foundation classes (UIKit, etc.) as they occur. I have used this plenty of time before to capture the line before my app crashes, but never realize I could make Xcode print out the actual exception error description before it halts the program completely. Notice the additional action to print the error message po $arg1. This is all we needed.

Adding an action to print the error message

To further make this Exception Breakpoint setting available for all the Xcode projects, you can move the breakpoint to User.

Try this out and let me know what exceptions this advanced trick helped you solve.

I learned this new trick from Paul Hudson at https://www.hackingwithswift.com/

Top comments (0)