How to enable SQL tracing/debugging for Core Data in Xcode 4.x

Core Data is a very powerful framework for data persistence, but there are times when something isn't working quite right and it may not be entirely obvious what the problem is. Trying to track down how to enable tracing in order to debug what's going on yields solutions for Xcode 3, yet nothing for Xcode 4.

It's not that difficult, you just have to know where to look:

  1. In the Schemes drop down select Edit Scheme...
  2. In the Arguments tab of the scheme, find the section entitled Arguments Passed On Launch
  3. Add a new argument as follows: -com.apple.CoreData.SQLDebug 1
  4. Click OK to save it

That's it! Follow those same steps and set it to 0 when you need to turn it off.

Posted on Dec 6
Written by Wayne Hartman