Xcode: One Weird Debugging Trick That Will Save Your Life
Ok, hope you can tell I was having way too much fun with this title 🙂 Anyway, now back to regularly scheduled programming…
Over the last few days, I’ve been watching the Advanced Debugging and the Address Sanitizer Session over breakfast. There is one super cool debugging trick that I have to write down so I remember to actually use it.
The Crash
The funny thing is that to write this blog post, I opened up a random test project I have, and 💥 it crashed in that horrible way we all dread:
The Trick
To see the real issue, click on the objc_exception_throw in your Thread to get the following:
Yes, I realize that this is all goobliegoo. But this is where the fun part is. Just type po $arg1 into the debug area to get the human-readable version of the error (in this case, the nib is invalid):
Oh ok, that’s an easy fix!
One More Advanced Trick
Finally, you can add the po $arg1 command to your Exception Breakpoint so it’s just automatic.
Happy Debugging!