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:
- In the Schemes drop down select Edit Scheme...
- In the Arguments tab of the scheme, find the section entitled Arguments Passed On Launch
- Add a new argument as follows:
-com.apple.CoreData.SQLDebug 1
- Click OK to save it
That's it! Follow those same steps and set it to 0 when you need to turn it off.