ios - Swift SourceKitService 崩溃

标签 ios core-data swift crash xcode6

我有一个使用 Core Data 的 Swift 项目,为 saveContext() 生成的代码导致 Xcode 崩溃并出现 SourceKitService Crashed 错误。当我将其注释掉时,错误停止,似乎是 self.managedObjectContext 导致了错误。我已经注释掉了我的代码,所以它就像一个新项目,但它仍然崩溃。谢谢

(Xcode 6.0.1)

func saveContext () {
    if let moc = self.managedObjectContext {
        var error: NSError? = nil
            if moc.hasChanges && !moc.save(&error) {
                // Replace this implementation with code to handle the error appropriately.
                // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                NSLog("Unresolved error \(error), \(error!.userInfo)")
                abort()
        }
    }
}

我创建了一个新项目并复制了我的代码,新项目没问题(而且完全一样)所以我已将此作为潜在错误报告给苹果。

谢谢

更新:

发现这个可以让事情变得更简单 :)

https://github.com/kattrali/deriveddata-exterminator

最佳答案

我会从事各种项目并不断遇到此错误,有时甚至会导致 Xcode 无法使用。我最终解决了这个问题,方法是退出 Xcode,清空 ~/Library/Developer/Xcode/DerivedData 文件夹,然后重新打开项目。

关于ios - Swift SourceKitService 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26230440/

相关文章:

ios - 拥有@2x 图像 Assets 而没有@1x Assets

iphone - 如何在UITableview的didSelectRowAtIndexPath中实现action?

iphone - 核心数据问题 - 选择分组依据/具有最大值

javascript - 在webview中动态隐藏部分html

ios - 在易出错的初始值设定项 swift 1.2 中分配 let 变量

swift - 如何使用 SwiftUI 的 onDelete() 函数访问数组位置

ios - 像 flipboard iPhone 应用程序这样的动画

ios - 无法在 iOS 的某些设备中获取 FCM 通知

iphone - 如何使用 Coredata 添加和使用现有的 SQLite 数据库(x.db)?

iphone - 将Core Data数据与外部数据库同步