com.apple.CoreData.SQLDebug 不工作 [英] com.apple.CoreData.SQLDebug not working

查看:19
本文介绍了com.apple.CoreData.SQLDebug 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 iOS 应用程序中在 MacOS Sierra 上使用 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.apple.CoreData.Logging.stderr 1 绕过它.

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.这实际上启用了 SQL 跟踪,而上面的内容会让您看到它.

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.

来自 https://developer.apple.com/library/content/releasenotes/General/WhatNewCoreData2016/ReleaseNotes.html

作为此转换的一部分,Core Data 尊重用户默认使用com.apple.CoreData.Logging.oslog"或com.apple.CoreData.Logging.stderr"登录到 os_log、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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆