When I’m debugging a universal iOS app, I’d like to be able to see the raw SQL in the logs. This blog post contains information on how to enable raw SQL logging for iOS Core Data development. The example given is for Xcode 3, and I’m not sure how to enable this in Xcode 4.
I tried “Product” -> “Edit Scheme” and added “-com.apple.CoreData.SQLDebug 1” to “Arguments Passed on Launch,” but the logs are still blank. I’m not sure if I’m looking in the wrong location or if the parameters are being passed wrongly.
Asked by oalders
You should look in the same place where you obtain your NSLOGS.
You should as well. To edit a scheme, go to Product -> Edit Scheme -> Then go to the main panel’s Arguments Tab and pick Run YOURAPP.app from the left panel.
An Argument Passed On Launch can be included there.
-com.apple.CoreData.SQLDebug 4 should be added (number between 1 and 4, higher number makes it more verbose)
Once you’ve pressed OK, you’re done.
The trick is to make changes to the scheme you’ll be testing with.
Answered by Nicolas S
It’s in the same folder that I keep track of my NSZombieEnabled.
Debug YouApp.app in Product -> Edit Scheme -> Run YouApp.app
Paste the following into the “Arguments Passed on Launch” box:
Warning: This stuff is verbose; if you’re having Core Data troubles, it’s worth looking at, but it could also be too much information about the incorrect item.
Answered by OverToasty
I was having trouble with this until I discovered it was due to a dumb omission, which I’m sure is a rookie error for several of you. I omitted the leading hyphen when entering the input in Xcode (4.3.1). If I had been putting it on the command line, I would not have done so, but I had omitted it in the GUI. I couldn’t tell the difference between entering two different arguments or just one (as some posts had suggested). As a result, use:
and not simply:
That worked in both the simulator and the real device for me.
Answered by user730458
It’s worth noting that several degrees of the value passed can be entered. Which results in an increase in verbosity.
-com.apple.CoreData.SQLDebug 1 -com.apple.CoreData.SQLDebug 2 -com.apple.CoreData.SQLDebug 3 -com.apple.CoreData.SQLDebug 4 // This will actually show parameter binds ("?")
Answered by netdigger
Post is based on https://stackoverflow.com/questions/6428630/xcode-4-and-core-data-how-to-enable-sql-debugging