Swift SourceKitService崩溃了

Day*_*and 30 crash core-data ios swift 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()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我创建了一个新项目并复制了我的代码,新项目很好(并且完全一样),所以我向苹果公司报告这是一个潜在的错误.

谢谢

更新:

找到这个让事情变得更容易:)

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

小智 64

我会处理各种项目并不断得到这个错误,有时候Xcode变得无法使用.我最终通过退出Xcode,清空~/Library/Developer/Xcode/DerivedData文件夹,然后重新打开项目来解决问题.

  • 所以这对我也有用.有趣的是,仅通过Xcode清除派生数据是不够的.完全吹掉目录的内容是什么伎俩. (8认同)
  • 在XCode 6.1中仍然看到相同的问题...和相同的解决方案. (3认同)