ios Xcode 4 和 Core Data:如何启用 SQL 调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6428630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4 and Core Data: How to enable SQL Debugging
提问by oalders
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 postabout 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.
我正在开发一个通用的 iOS 应用程序,我想在调试时查看日志中的原始 SQL。这篇博文中有一些关于如何为 iOS 核心数据开发启用原始 SQL 日志记录的信息。给定的示例适用于 Xcode 3,我不清楚如何在 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.
我试过“产品”->“编辑方案”并将“ -com.apple.CoreData.SQLDebug 1”添加到“启动时传递的参数”,但我仍然没有在日志中看到任何输出。不确定我是找错了地方还是只是错误地传递了参数。
回答by Nicolas S
You should be looking at the same place you get NSLOGS
您应该查看获得 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.
您应该转到 Product -> Edit Scheme -> 然后从左侧面板中选择 Run YOURAPP.app 并转到主面板的 Arguments 选项卡。
There you can add an Argument Passed On Launch.
在那里你可以添加一个 Argument Passed On Launch。
You should add -com.apple.CoreData.SQLDebug 4
(number between 1 and 4, higher number makes it more verbose)
您应该添加-com.apple.CoreData.SQLDebug 4
(1 到 4 之间的数字,数字越大,说明越详细)
Press OK and your are all set.
按OK,你的一切都设置好了。
The key here is to edit the scheme you will be using for testing.
这里的关键是编辑您将用于测试的方案。
回答by OverToasty
XCode 4
代码 4
It's in the same place I manage my NSZombieEnabled
它在我管理我的 NSZombieEnabled 的同一个地方
Product -> Edit Scheme -> Run YouApp.app Debug
Product -> Edit Scheme -> Run YouApp.app Debug
Under "Arguments Passed on Launch", paste in exactly:
在“启动时传递的参数”下,准确粘贴:
-com.apple.CoreData.SQLDebug 1
-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.
警告 - 这些内容非常冗长,如果您遇到 Core Data 问题,这可能值得一看,但它也可能比您需要的关于错误的信息更多。
回答by user730458
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:
我遇到了这个问题,然后意识到这是一个愚蠢的遗漏,我认为这对你们中的一些人来说是一个错误。当我在 中输入参数时Xcode (4.3.1)
,我省略了前导连字符。我不会做这么被我进入它的命令行中,但在GUI我遗漏了它。我没有找到进入在2个独立的ARGS或一个(一些职位曾建议)之间的任何差别。所以使用:
-com.apple.CoreData.SQLDebug 1
-com.apple.CoreData.SQLDebug 1
and not simply:
而不仅仅是:
com.apple.CoreData.SQLDebug 1
com.apple.CoreData.SQLDebug 1
that worked for me in both simulator and real device
在模拟器和真实设备中都对我有用
回答by netigger
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 ("?")