Coder Perfect

How to Enable SQL Debugging in Xcode 4 with Core Data


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 “ 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

Solution #1

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 from the left panel.

An Argument Passed On Launch can be included there. 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

Solution #2

XCode 4

It’s in the same folder that I keep track of my NSZombieEnabled.

Debug in Product -> Edit Scheme -> Run

Paste the following into the “Arguments Passed on Launch” box: 1

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

Solution #3

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: 1

and not simply: 1

That worked in both the simulator and the real device for me.

Answered by user730458

Solution #4

It’s worth noting that several degrees of the value passed can be entered. Which results in an increase in verbosity. 1 2 3 4 // This will actually show parameter binds ("?")

Answered by netdigger

Post is based on