Selecting executable in XCode
There are a number of useful debug flags for the iPhone that can be set in the environment. To access these settings, select your executable from the Groups & Files pane in XCode, then press ?I or select Get Info from the context menu.

Go to the Arguments tab and add the following entries into the “Variables to be set in the environment” box:

  • NSAutoreleaseFreedObjectCheckEnabled
  • NSDebugEnabled
  • NSZombieEnabled

Set the value for all each to YES.

Your settings should now look like:

Executable arguments settings

You may also want to set NSHangOnUncaughtException=YES. Additional useful debugging tips can be found in this thread.

Edit: CocoaDev has additional NSZombieEnabled tips, and notes that you may not want to leave this enabled all the time, especially if your application churns through a lot of objects, as the memory never gets freed. The fact that your code is running on a desktop or laptop system instead of the phone helps a lot here, so this is probably a lot less of a concern than for a desktop application. They also provide instructions for setting these flags in your .gdbinit using:

set env NSAutoreleaseFreedObjectCheckEnabled=YES
set env NSDebugEnabled=YES
set env NSZombieEnabled=YES

Tags: