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:

Screen Shot 2015-06-30 at 6.17.04 AM

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.

Screen Shot 2015-06-30 at 6.28.21 AM

Happy Debugging!

Enjoy the article? Join over 14,500+ Swift developers and enthusiasts who get my weekly updates.

  • Hey Natasha, Thank for the tip! I still hate debugging Swift, little bit less now 😉

  • Kevin DeLeon

    Great tips as usual Natasha! Adding it to the Exception Breakpoint is super handy.

  • Darren Gillman

    ooh! That’s neat.

  • willhains

    Thanks as always, Natasha. Of course, since this is such a common thing, Xcode should just, y’know, do that for us automatically. Sigh.

  • Pingback: Michael Tsai - Blog - Debugging Exceptions in Xcode()

  • Tan YongSheng

    This is real cool. Another Bookmark site on Chrome.

  • This is awesome! I had an error last night that this works for. Thanks

  • Kakubei

    Natasha, you are awesome!

  • Kakubei

    Oh no, when I tried this Xcode throws an error:

    (lldb) po $arg1
    error: :1:1: error: use of unresolved identifier ‘$arg1’

    • I have the same error ! If you find a solution, let me know 🙂

    • Are you in Xcode 7 beta? I thought it would work in other Xcode versions, but maybe not?

      • Kakubei

        Yes, Xcode 7 beta. Which version of Xcode did you find it works with?

        • Got it. Yes, using Xcode 7 beta. I think you have to be in the obj_exception_throw type of error. In your case, the $arg1 is actually not defined, since it’s a different type of error.

          • Kakubei

            Thanks Natasha! I appreciate you taking the time to investigate and reply.

          • matthewflint

            Try instead “po $eax” (for 32 bit simulator) or “po $rax” (64 bit simulator).

            “po $r0” if you’re debugging on a device.

  • Derlon

    nice thks!

  • JerryR

    Thank you!

  • l2succes

    Wow, that’s so dope! Thanks for sharing this 😉

  • Franck

    Great. Thks!

  • Sidney de Koning

    And if you ctrl-click on the breakpoint and select ‘Move breakpoint to => user’, you have it in every project you create 🙂 Double the awesomeness!


  • Pingback: Advanced Debugging in Xcode and Swift : Confessions of a Flash Addict()

  • finneycanhelp

    saved my life today. 😉

  • @sidneydekoning:disqus Thanks for the tip to move this to user as well.

  • As always Natasha, thanks for another helpful post.

  • zjczhjuncai

    Thanks Natasha, great to know

  • Nicholas Michael

    I love this trick! SO helpful. Thanks Natasha!

  • pallzoltan

    You’d think Apple would have done this automatically by now, but no, Apple is on to some weird shit always…