com.apple.CoreData.SQLDebug不工作 [英] com.apple.CoreData.SQLDebug not working
问题描述
我在MacOS Sierra的iOS应用程序中使用Xcode 8和swift。我意识到几个月前,SQLDebug停止工作...(它以前在我的应用程序工作)...
I'm working with Xcode 8 with swift on MacOS Sierra in an iOS app. I realized a few months ago that the SQLDebug stops working... (It used to worked in my app)...
我创建了一个新的空项目, coredata标志启用...然后我创建了一个具有属性的实体,我在ViewDidLoad中执行了这个函数,Xcode没有记录sql
I have created a new empty project with the coredata flag enabled..Then I created an entity with attributes and I executed this func in the ViewDidLoad and Xcode is NOT logging the sql
func fetchAllData(){
//1 delegate
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.persistentContainer.viewContext
//2 prepare fetch request
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName:"Entrenamientos")
//3 make fetch
do{
let fetchedResults = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
}
catch{
}
}
推荐答案
Core Data使用从iOS 10开始的新的统一日志记录框架。在Xcode中有一个已知的问题会干扰日志记录,但您可以使用-com。
Core Data uses the new unified logging framework starting with iOS 10. There is a known issue in Xcode that interferes with the logging, but you can use -com.apple.CoreData.Logging.stderr 1 to get around it.
编辑:为了清楚,您必须指定-com.apple.CoreData.SQLDebug 1除了上面的。
For clarity, you must specify -com.apple.CoreData.SQLDebug 1 in addition to the above. This actually enables the SQL trace, while the above will let you see it.
作为此转换的一部分,Core Data通过'com.apple.CoreData.Logging.oslog'或'com.apple.CoreData.Logging.oslog'授权用户默认登录到os_log,stderr, com.apple.CoreData.Logging.stderr。由于Xcode中的已知问题,在调试期间切换stderr日志记录可能很有用。
As part of this transition, Core Data honors user defaults to log to os_log, stderr, or both with ‘com.apple.CoreData.Logging.oslog’ or ‘com.apple.CoreData.Logging.stderr’. Due to a known issue in Xcode, it may be useful to toggle stderr logging on during debugging.
控制台应用程序,它将显示与您的Mac连接的设备的日志。
You might also look in the new Console app, which will display logs from devices connected to your Mac.
这篇关于com.apple.CoreData.SQLDebug不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!