When debugging Objective-C applications, it’s really useful to be able to see where uncaught exceptions are generated. Let’s see how this can be achieved using Xcode (current version 4.3.2) or JetBrains AppCode (current version 1.5.2).
Using Xcode
First show the Breakpoint Navigator, either from the View / Navigators menu, or using the keyboard shortcut ⌘6. By default you won’t see any breakpoints just yet. From the lower-left corner, press the + symbol to add a new breakpoint, and select “Add Exception Breakpoint” from the menu.
That will take you to the next step, where you just need to press the Done button:
Now, whenever an uncaught exception is generated while the current project is being debugged, Xcode will stop the execution and take you to the line where the exception has taken place. If you’d like this behavior in all your projects without having to go through the above steps each time, just right click on the “All Exceptions” breakpoint you previously added and choose Move Breakpoint To User. That’s it.
Using AppCode
If you’re using the cool AppCode IDE for developing Obj-C apps, there is a way to achieve the same behavior in that as well. Open the project in AppCode and navigate to the Run / View Breakpoints menu, or use the shortcut ⇧⌘F8. Then choose the tab called Exception Breakpoints. By default that section is empty.
Now simply press the Add button on the right hand side of the dialog to get the following result:
That will give you a breakpoint which will suspend the execution of your application whenever an exception is thrown. You can further customize the behavior in such cases by logging the corresponding message to the console, for example.
Happy debugging everyone.












