Pause Xcode 5.1 on Objective-C exceptions
A quick tutorial with screenshots
By default Xcode won't stop the debugger when an exception occurs. Instead it will just allow your app to crash. It can be helpful to inspect the state of the app at the point where the exception is thrown rather than reading through the logs after the fact.
By default, when you create a breakpoint, it's only for the current project. These steps show you how to make one that will stick around for all your projects.
Steps
- Open your Xcode project or workspace and pull up the Breakpoint Navigator.
View --> Navigators --> Show Breakpoint Navigator
orCommand + 7
- Click the plus in the lower left hand corner and select
Add Exception Breakpoint
- Right click on the
All Exceptions
breakpoint that was created, and selectMove BreakPoint To --> User
.
Optional steps: Filter exception type
Some projects may not have this problem, but mine has non-Objective-c exceptions thrown regularly and I haven't figured out how to get rid of them. So I set my breakpoint to only stop on Objective-C exceptions.
- Right click on the breakpoint and choose
Edit
- Change the Exception drop down from
All
toObjective-C
Finally, I recommend you ask everyone on your team to do the same. You'll find issues earlier. You may have exceptions being thrown in your project under non-exceptional circumstances currently. These make your breakpoint pretty useless. It can be some work to get rid those non-exceptional exceptions, but I think you'll find that work to be a worthwhile investment of your time.
If you have any questions / suggestions / feedback, please leave a comment.
Manhattan mobile software engineer.