我在Xcode中遇到了一个问题,错误“源套件服务终止”正在弹出,所有语法高亮显示和代码完成都在Swift中消失了。我该如何解决这个问题?
下面是一个示例图像:
我在Xcode中遇到了一个问题,错误“源套件服务终止”正在弹出,所有语法高亮显示和代码完成都在Swift中消失了。我该如何解决这个问题?
下面是一个示例图像:
当前回答
我在嵌套的objective - c++项目中也犯了同样的错误,该项目现在包含了带有Swift代码的框架。为了解决这个问题,我必须明确地构建框架。一旦我做了,那期就没了,再也不会回来了;)
其他回答
我在苹果的开发者论坛上找到了一个解决方案(需要登录,所以我也会在这里解释)。
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
在项目中使用Swift以外的其他名称。“Swift”是保留的。
对我来说(xcode 6.1),原因是我忘记采用我的子类协议。
例如,这是错误的:
protocol SomeProtocol { ... }
class A :NSObject, SomeProtocol {
...
}
class B : A {
...
}
这是可以的:
protocol SomeProtocol { ... }
class A : NSObject, SomeProtocol {
...
}
class B : A, SomeProtocol {
...
}
我在Xcode6 beta 3中创建了一个在beta 2中创建的项目,遇到了同样的问题。
这是因为swift语言中出现了新的突破性变化,即数组声明语法。
检查受影响的代码由于破坏性的变化在beta 3。
http://adcdownload.apple.com//Developer_Tools/xcode_6_beta_3_lpw27r/xcode_6_beta_3_release_notes__.pdf
我的例子之一是:
我不得不改变:
var tabBarController : UITabBarController = self.window?.rootViewController as UITabBarController;
to
var tabBarController : UITabBarController = self.window!.rootViewController as UITabBarController
结论:看起来如果源代码中有错误,在某些情况下这个错误是由Xcode产生的。
解决方案,直到bug被修复:手动检查错误:)
古德勒克!
我在嵌套的objective - c++项目中也犯了同样的错误,该项目现在包含了带有Swift代码的框架。为了解决这个问题,我必须明确地构建框架。一旦我做了,那期就没了,再也不会回来了;)