Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Xcode4 stop at NSAssert failure?

Tags:

xcode4

Currently, my Xcode4 does not stop at NSAssert failure. How can I make it stop at NSAssert failure again?

like image 603
eonil Avatar asked May 15 '11 10:05

eonil


1 Answers

  1. Go to the XCode 4 breakpoint navigator.
  2. Click the + button and choose "Add Symbolic Breakpoint"
  3. Set Symbol: to "-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]"
  4. Click "Done"

Now you will stop in the debugger as soon as NSAssert fires. In my testing, it goes to the nearest source code and doesn't just show you the assembly where you set the breakpoint.

More Generically, you could do this:

  1. Go to the breakpoint navigator.
  2. Click the + button and choose "Add Exception Breakpoint"
  3. Set Exception: to "Objective-C"
  4. Set Break: to "On Throw"
  5. Click "Done"

This may be more or less useful depending on your code.

See also the XCode 4 documentation result for "Adding an Exception Breakpoint"

like image 131
Walt Sellers Avatar answered Nov 10 '22 22:11

Walt Sellers