我有一个使用 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()
}
}
}
我创建了一个新项目并复制了我的代码,新项目没问题(而且完全一样)所以我已将此作为潜在错误报告给苹果。
谢谢
更新:
发现这个可以让事情变得更简单 :)
最佳答案
我会从事各种项目并不断遇到此错误,有时甚至会导致 Xcode 无法使用。我最终解决了这个问题,方法是退出 Xcode,清空 ~/Library/Developer/Xcode/DerivedData
文件夹,然后重新打开项目。
关于ios - Swift SourceKitService 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26230440/