我在Xcode中遇到了一个问题,错误“源套件服务终止”正在弹出,所有语法高亮显示和代码完成都在Swift中消失了。我该如何解决这个问题?

下面是一个示例图像:


当前回答

xcode 6 Version 6.0 (6A313)仍然存在

创建一个新项目 添加一个框架和库 选择cocoa触摸框架 添加Swift文件 向swift文件中添加一个类

崩溃

Ps:全新的MAC mini,没有之前的xcode安装,没有任何异国情调。我想只是个测试版产品。

其他回答

如果Xcode打开,退出Xcode。然后从终端运行:

defaults delete com.apple.dt.Xcode

这将把Xcode恢复到默认设置。打开Xcode,一切都可以正常工作了。

我相信我找到了一个更通用的解决方案。下面是我用来鼓励Xcode不要产生SourceKitService Terminated错误的步骤。


我的症状是:

When I would start up a new playground, I would receive an error about not being able to communicate with the playground (Error running playground: Failed prepare for communication with playground. See this image on twitter. When I would switch the playground from OS X to iOS, I would receive another error (unfortunately I did not write that one down). When I would start to type in an iOS based Swift project, attempting to use code completion/intellisense on any UIKit specific class, I would receive the SourceKitService Terminated issue in this thread.


调试过程:

我开始通过谷歌寻找SourceKitService,这得到了很少。 然后我开始监视控制台。应用程序,同时使用Xcode。这显示了几个错误: IDEPlaygroundDocument:运行游乐场时遇到错误 com.apple.CoreSimulator。CoreSimulatorService[3952]: The runtime for The selected device is not installed。


我做了什么来纠正这个问题。

如果您只是在Swift项目上下文中遇到问题,请先单独尝试一下。如果这不起作用,那么尝试下面的所有步骤。

打开项目并将目标的部署目标更改为<= 7.1。

更漫长和复杂的过程。 (前3步不一定有帮助,但我做到了,所以把它们记录在这里)

Completely delete all copies of Xcode on your system. Restart your computer. Reinstall Xcode6-beta only. Verify that you still have the issue in playground and/or projects. Open iOS Simulator. Hardware -> Device -> Manage Devices Remove all devices. Recreate all devices you want. I appended the iOS version to the end of the name, just because. Restart Xcode and the simulator. Verify that at least playgrounds no longer throw issues when switched from OS X to iOS. Open your project and change the target's deployment target to something <= 7.1.


分析

看来问题是Xcode6不能正确地找到并连接到模拟器。我不知道为什么会出现这种情况,但这让我可以继续使用Swift进行开发。这可能与模拟器二进制文件似乎移动的事实有关。

问题:

如果源代码中有错误,可能会弹出“SourceKitService Terminated”,代码高亮显示停止工作。它可能发生,也可能不发生,当它发生在多种不同的条件下。

我的案例:安装beta 3, OSX仅项目,一个文件检测到“半封闭范围操作符已从..对. .<”错误。弹出窗口开始出现,代码高亮显示开始失败。

解决方案:

修复Xcode检测到的错误 在Navigator中更改为不同的.swift,回到原来的 语法高亮显示重新出现,“SourceKitService Terminated”弹出

在我的情况下,我已经导入桥接头丢失的文件。在我删除错误导入后,错误通知消失了。

在项目中使用Swift以外的其他名称。“Swift”是保留的。