我在Xcode中遇到了一个问题,错误“源套件服务终止”正在弹出,所有语法高亮显示和代码完成都在Swift中消失了。我该如何解决这个问题?
下面是一个示例图像:
我在Xcode中遇到了一个问题,错误“源套件服务终止”正在弹出,所有语法高亮显示和代码完成都在Swift中消失了。我该如何解决这个问题?
下面是一个示例图像:
当前回答
报告给苹果公司(#17266321):
细节:
简介: 如果我们试图将值作为数组打印一个字典,则弹出窗口会不断弹出-“SourceKit terminated.”编辑器功能暂时受限”。Xcode冻结并失去上下文识别,导致文本变黑。
复制步骤: 1. 创建一个数组为- "var iOSHistoryArray = ["iOS6","iOS7","iOS8",]"
创建一个字典as -"var MacOSYosemiteFeatures: dictionary = ["Device":iOSHistoryArray]"。 将字典打印为- "println("包含数组值的字典:%@ \n",MacOSYosemiteFeatures)"(< < -罪魁祸首——> >) 第3步导致了注释问题,这使得Xcode再次起作用。
预期结果: Xcode应该能正常工作。
实际结果: Xcode变得无功能,失去上下文识别(所有字体丢失,所有文本变成纯黑色),整个Xcode变成非活动。
版本: 版本6.0 (6A215l)
其他回答
在我的情况下,我已经导入桥接头丢失的文件。在我删除错误导入后,错误通知消失了。
当此错误开始弹出时,只需注释掉您编写的最后/最近的一段代码并等待一段时间。语法高亮显示应该会重新出现。这就是我解决这个问题的方法。
func someFunc() -> (Int?, Int?, Int?) {
var retVal1:Int? = nil
var retVal2:Int? = nil
var retVal3:Int? = nil
//some other code
//commenting out the line below helped me
//(retVal1, retVal2, retVal3)
return (retVal1, retVal2, retVal3)
}
在项目中使用Swift以外的其他名称。“Swift”是保留的。
你的项目叫Swift吗?看到这个消息,构建也会失败(<unknown>:0: error:模块名“Swift”是为标准库保留的)。尝试使用其他项目名称,例如SwiftTest。它会起作用的。
我在苹果的开发者论坛上找到了一个解决方案(需要登录,所以我也会在这里解释)。
TLDR:不要在Objective-C中导入与@interface同名的@protocol到Swift桥接头。例如,Facebook SDK有一个名为“FBGraphObject”的协议和接口。
以下是论坛帖子:
Adding Facebook SDK causes SourceKitService to crash. If you want to use beta 3 and you need Facebook SDK, one work around that I found and is working for me is refactoring Facebook SDK's @protocol FBGraphObject and renaming it to something like @protocol FBGraphObjectProtocol as an @interface FBGraphObject also exists and apparently SourceKit doesn't like it. It sure is a temporary solution just to keep you functional and you'll have to use Cocoapods or otherwise build Facebook SDK yourself rather than using the framework library. For the time being, you'll need to make sure you don't have conflicting @protocol and @interface declarations and that includes 3rd party libraries you may be using. This cost me today, hope it helps! Posted by e.parto on July 10, 2014