Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4 and Core Data: How to enable SQL Debugging

I'm working on a universal iOS app and I'd like to see the raw SQL in the logs when I'm debugging. There is some info in this blog post about how to enable raw SQL logging for iOS Core Data development. The given example is for Xcode 3 and it's just not clear to me how to enable this in Xcode 4.

I've tried "Product" -> "Edit Scheme" and added "-com.apple.CoreData.SQLDebug 1" to "Arguments Passed on Launch", but I'm still not seeing any output in the logs. Not sure if I'm looking in the wrong place or just passing the arguments incorrectly.

like image 466
oalders Avatar asked Jun 21 '11 16:06

oalders


4 Answers

You should be looking at the same place you get NSLOGS

And you should Go to Product -> Edit Scheme -> Then from the left panel select Run YOURAPP.app and go to the main panel's Arguments Tab.

There you can add an Argument Passed On Launch.

You should add -com.apple.CoreData.SQLDebug 4 (number between 1 and 4, higher number makes it more verbose)

Press OK and your are all set.

The key here is to edit the scheme you will be using for testing.

like image 99
Nicolas S Avatar answered Nov 12 '22 10:11

Nicolas S


XCode 4

It's in the same place I manage my NSZombieEnabled

Product -> Edit Scheme -> Run YouApp.app Debug

Under "Arguments Passed on Launch", paste in exactly:

-com.apple.CoreData.SQLDebug 1

Warning - this stuff is very verbose, if you're having Core Data issues, this might be well worth looking at, but it may also be more info than you need about the wrong thing.

like image 28
OverToasty Avatar answered Nov 12 '22 09:11

OverToasty


I was having a problem with this and then realized it was a silly omission, which I assume is a comer mistake for some of you. When I entered the argument in Xcode (4.3.1), I left out the leading hyphen. I wouldn't have done so were I entering it on a command line, but in the GUI I had omitted it. I didn't find any difference between entering at 2 separate args or one (as some posts had suggested). So use:

-com.apple.CoreData.SQLDebug 1

and not simply:

com.apple.CoreData.SQLDebug 1

that worked for me in both simulator and real device

like image 5
user730458 Avatar answered Nov 12 '22 11:11

user730458


Note that you can put in different levels of the value passed. Which provide more and more 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 ("?")
like image 4
netdigger Avatar answered Nov 12 '22 09:11

netdigger