I’m sure you’ve often wanted to inspect the return value of a method in Xcode’s debugger with breakpoints. But because you can’t put a breakpoint after the last line of a method, it becomes slightly tricky to figure out the return value. Thankfully, there’s an easy trick.

First, add a breakpoint to the last line of the method:

image

Build and run your project, and let Xcode break at the last line. Then, click on the “step out” button in the debugger panel:

image

After clicking the button, the control goes to the caller of this method, and in addition to the other variables in the current scope, you’ll also see a “Return Value” in the Variables View, from where you can inspect it, QuickLook preview it (click + space bar), print its description etc.

image
image

As you might have noticed in the code fragment at the top, I’m returning the UIBezierPath directly without storing it in an intermediate variable, so it wasn’t immediately obvious as to how to inspect it in the debugger. With this trick, you can inspect the return value without having to change your code and introduce an intermediate variable.