Sometimes Xcode just throws an error message that isn’t very helpful. That’s usually when we have to try and figure out why something didn’t go the way we expected it. Other times however, Xcode tells us very clearly which element it isn’t happy with – we fix it and our app progresses. Why can’t it always be that way?
Well that’s because at those unhelpful times, Xcode is technically picking up an “exception”, but it tries to continue to run the programme. That’s when we end up with an error message which isn’t related to the actual problem.
An Exception Breakpoint can help. It’s something we can set and therefore force Xcode to stop when the problem occurs, not several lines later. Here’s how we do it:
- with the Navigator pane open, select the 6th tab from the left (the Breakpoint Navigator)
- at the bottom left, click the plus sign to add a breakpoint
- from the context menu select Add Exception Breakpoint
- leave all default values and hit Done
Next time Xcode will not try to be heroic and keep going. Instead, expect a more helpful error message.