Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NSzombie in xcode? [duplicate]

Tags:

xcode

nszombie

I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing".

Does anybody know how to enable NSZombie in Xcode 4?

like image 537
jason Avatar asked Mar 22 '11 02:03

jason


5 Answers

Environment variables are now part of the "scheme".

To edit the scheme and turn on zombies:

  • In the "Product" menu, select "Edit Scheme".

  • Go to the "Run Foo.app" stage in the left panel, and the "Arguments" tab on the right.

  • Add NSZombieEnabled to the "Environment Variables" section and set the value to YES, as you could in Xcode 3.


In Xcode 4.1 and above, there's also a checkbox on the "Diagnostics" tab of the "Run" stage to "Enable Zombie Objects".


With Xcode 6.4:

Screenshot

like image 76
一二三 Avatar answered Oct 22 '22 22:10

一二三


I encountered the same problem with troubleshooting EXC_BAD_ACCESS and had hard time to find the setting with Xcode 4.2 (the latest one that comes with iOS5 SDK). Apple keeps on moving things and the settings are no longer where they used to be.

Fortunately, I've found it and it works for the device, not just Simulator. You need to open the Product menu in the Xcode, select Edit scheme and then choose the Diagnostics tab. There you have "Enable Zombie Objects". Once selected and run in debugger will point you to the double released object! Enjoy!

In short

Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects
like image 38
Moshe Kravchik Avatar answered Oct 22 '22 21:10

Moshe Kravchik


Product > Profile will launch Instruments and then you there should be a "Trace Template" named "Zombies". However this trace template is only available if the current build destination is the simulator - it will not be available if you have the destination set to your iOS device.

Also another thing to note is that there is no actual Zombies instrument in the instrument library. The zombies trace template actually consists of the Allocations instrument with the "Enable NSZombie detection" launch configuration set.

like image 24
Shane Fitzgibbon Avatar answered Oct 22 '22 22:10

Shane Fitzgibbon


It's a simple matter of setting an environment variable on your executable (NSZombieEnabled = YES), and then running/debugging your app as normal.If you message a zombie, your app will crash/break to debugger and NSLog a message for you.

For more information, check out this CocoaDev page: http://www.cocoadev.com/index.pl?NSZombieEnabled

Also, this process will become much easier with the release of 10.6 and the next versions of Xcode and Instruments. Just saying'. =)

like image 45
Dave DeLong Avatar answered Oct 22 '22 20:10

Dave DeLong


Product > Profile will pop up Instruments. Select zombies from the panel and go nuts.

like image 22
pseudosudo Avatar answered Oct 22 '22 22:10

pseudosudo