Swift SourceKitService崩溃

我有一个使用核心数据的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() } } } 

我做了一个新的项目,并且复制了我的代码,新项目也没问题(完全一样),所以我已经把这个报告给了苹果作为一个潜在的bug。

谢谢

更新:

发现这使事情变得更容易:)

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

我会在各种项目上工作,并不断得到这个错误,有时甚至到Xcode变得无法使用的地步。 我最终通过退出Xcode解决了这个问题,清空~/Library/Developer/Xcode/DerivedData文件夹,然后重新打开项目。

苹果解决这个崩溃版本:6.1.1

版本6.1.1中的新function

包括适用于OS X 10.10 Yosemite,OS X 10.9 Mavericks和iOS 8.1的SDK

 • Fixes common causes of SourceKit crashes when working with Swift • Additional bug fixes and stability improvements 

https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12

你也可以使用下面的path删除你的项目来解决这个问题

〜/资源库/开发/ Xcode中/ DerivedData