ios SourceKitService 终止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24006206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SourceKitService Terminated
提问by Tony
I am having a issue with Xcode where the error "Source Kit Service Terminated" is popping up and all syntax highlighting and code completion is gone in Swift. How can I fix this?
我遇到了 Xcode 问题,其中弹出错误“Source Kit Service Terminated”,并且所有语法突出显示和代码完成在 Swift 中都消失了。我怎样才能解决这个问题?
Here is an example image:
这是一个示例图像:
采纳答案by tobygriffin
The answer to mine (Xcode6-Beta7) was simply to delete the Derived Data folder.
我的答案(Xcode6-Beta7)只是删除派生数据文件夹。
Preferences > Locations > Derived Data > click the arrow to open in Finder > trash it.
Preferences > Locations > Derived Data > click the arrow to open in Finder > trash it.
Hope this helps someone. There's obviously many reasons why this crash can occur.
希望这可以帮助某人。发生这种崩溃的原因显然有很多。
回答by Andrew Monshizadeh
I believe I may have found a more general purpose solution. Below are the steps I used to encourage Xcode not to produce the SourceKitService Terminated
error.
我相信我可能已经找到了一个更通用的解决方案。下面是我用来鼓励 Xcode 不要产生SourceKitService Terminated
错误的步骤。
The symptoms I was having:
我当时的症状:
- 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
toiOS
, 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.
- 当我启动一个新的 Playground 时,我会收到一个关于无法与 Playground 通信的错误(
Error running playground: Failed prepare for communication with playground.
参见twitter 上的这张图片。 - 当我将操场从 切换
OS X
到 时iOS
,我会收到另一个错误(不幸的是我没有把那个写下来)。 - 当我开始输入基于 iOS 的 Swift 项目,尝试在任何 UIKit 特定类上使用代码完成/智能感知时,我会
SourceKitService Terminated
在此线程中收到问题。
Debugging process:
调试过程:
- I started by looking through google for SourceKitService, this got very little.
- I then started monitoring Console.app while using Xcode. This showed a couple errors:
IDEPlaygroundDocument: Error encountered running playground
com.apple.CoreSimulator.CoreSimulatorService[3952]: The runtime for the selected device is not installed.
- 我开始通过谷歌寻找 SourceKitService,这得到的很少。
- 然后我开始在使用 Xcode 时监控 Console.app。这显示了几个错误:
IDEPlaygroundDocument: Error encountered running playground
com.apple.CoreSimulator.CoreSimulatorService[3952]: The runtime for the selected device is not installed.
What I did to correct this issue.
我做了什么来纠正这个问题。
If you are only having an issue within the context of a Swift project, try this alone first. If that doesn't work, then try all of the steps further below.
如果您只是在 Swift 项目的上下文中遇到问题,请先单独尝试。如果这不起作用,请尝试以下所有步骤。
- Open your project and change the target's deployment target to something <= 7.1.
- 打开您的项目并将目标的部署目标更改为 <= 7.1。
The more lengthy and involved process. (The first 3 steps are not for sure helpful, but I did them, and so record them here)
更漫长和复杂的过程。(前 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
toiOS
. - Open your project and change the target's deployment target to something <= 7.1.
- 完全删除系统上所有 Xcode 副本。
- 重启你的电脑。
- 仅重新安装 Xcode6-beta。
- 确认您在 Playground 和/或项目中仍然存在问题。
- 打开 iOS 模拟器。
- 硬件 -> 设备 -> 管理设备
- 移除所有设备。
- 重新创建您想要的所有设备。我将 iOS 版本附加到名称的末尾,只是因为。
- 重新启动 Xcode 和模拟器。
- 验证至少 Playgrounds 在从 切换
OS X
到时不再抛出问题iOS
。 - 打开您的项目并将目标的部署目标更改为 <= 7.1。
Analysis
分析
It appears the issue is with Xcode6 not being able to properly find, and connect, to the simulator. I have not been able to determine why this is the case, but this has allowed me to continue developing with Swift. This may have to do with the fact the simulator binaries seem to have moved.
问题似乎是 Xcode6 无法正确找到并连接到模拟器。我无法确定为什么会出现这种情况,但这使我能够继续使用 Swift 进行开发。这可能与模拟器二进制文件似乎已经移动的事实有关。
回答by David Attias
You just need to delete the "ModuleCache", this is some kind of cache used by Xcode for Autocompletion.
您只需要删除“ModuleCache”,这是 Xcode 用于自动完成的某种缓存。
Copy and paste the following line in the Terminal:
在终端中复制并粘贴以下行:
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache
回答by Klaas
SourceKitService crashes on my system as soon as I type
我输入后 SourceKitService 在我的系统上崩溃
extension foo {
I'm using Xcode 6 beta 6 and it does not matter if I type it into an empty file or add it to an existing one. As soon as the source contains one extension
block, it will crash. This happens even on newly created projects.
我正在使用 Xcode 6 beta 6,无论是将它输入到一个空文件中还是将其添加到现有文件中都没有关系。只要源包含一个extension
块,它就会崩溃。即使在新创建的项目上也会发生这种情况。
My "solution" is to avoid extension in the sources I'm currently working on. I comment out the end of a class block and the beginning of the extension block. As soon as I have finished my work on the class, I comment them in again:
我的“解决方案”是避免扩展我目前正在处理的资源。我注释掉类块的结尾和扩展块的开头。一旦我完成了我在课堂上的工作,我再次评论它们:
class MyClass {
[... my stuff ...]
//}
//
//extension MyClass {
}
回答by Markus Buhl
It started happening on my spritekit project after inserting the touchesMoved-function. This function uses forced unwrapping, which seems to cause the problem:
插入 touchesMoved 函数后,它开始发生在我的 spritekit 项目中。这个函数使用了强制解包,这似乎导致了问题:
override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!)
After removing the exclamation marks and thus stopping forced unwrapping, the SourceKitService stopped crashing.
删除感叹号并因此停止强制展开后,SourceKitService 停止崩溃。
Hope this helps!
希望这可以帮助!
回答by aleclarson
I found a solutionon Apple's Developer Forums (which requires login, so I'll explain it here too).
我在 Apple 的开发者论坛上找到了一个解决方案(需要登录,所以我也会在这里解释)。
TLDR: Don't import a @protocol
in your Objective-C to Swift bridging header that is named the same as an @interface
. For example, the Facebook SDK has both a protocol and an interface named "FBGraphObject".
TLDR:不要@protocol
在您的 Objective-C中将a 导入到与@interface
. 例如,Facebook SDK 有一个名为“FBGraphObject”的协议和一个接口。
Here's the forum post:
以下是论坛帖子:
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.partoon July 10, 2014
添加 Facebook SDK 会导致 SourceKitService 崩溃。如果您想使用 beta 3 并且需要 Facebook SDK,我发现并为我工作的一项解决方法是重构 Facebook SDK 的 @protocol FBGraphObject 并将其重命名为 @protocol FBGraphObjectProtocol 之类的东西,因为 @interface FBGraphObject 也存在并且显然 SourceKit不喜欢。
这确实是一个临时解决方案,只是为了保持您的功能,您必须使用 Cocoapods 或以其他方式自己构建 Facebook SDK,而不是使用框架库。
目前,您需要确保 @protocol 和 @interface 声明没有冲突,并且包括您可能正在使用的 3rd 方库。
今天花了我,希望它有帮助!
e.parto发表于2014年7 月 10 日
回答by Caroline
I had this problem every few seconds in Xcode 6 Beta 3, and it continued even in completely new projects. I changed the Deployment Target from 8.0 to 7.1 and it has stopped.
我在 Xcode 6 Beta 3 中每隔几秒钟就会遇到这个问题,即使在全新的项目中它也会继续存在。我将部署目标从 8.0 更改为 7.1,但它已停止。
回答by Marius Fanu
Use other name than Swift for the project. "Swift" is reserved.
为项目使用 Swift 以外的其他名称。“斯威夫特”是保留的。
回答by devxoul
Is your project named Swift
? With seeing that message, build would be failed too(<unknown>:0: error: module name "Swift" is reserved for the standard library
). Try using another project name such as SwiftTest
. It would work.
你的项目有名字Swift
吗?看到这条消息,构建也会失败(<unknown>:0: error: module name "Swift" is reserved for the standard library
)。尝试使用其他项目名称,例如SwiftTest
. 它会工作。
回答by Olshansk
I found that by explicitly (statically) typing the variable types, rather than inferring them, solved the issue for me.
我发现通过显式(静态)键入变量类型,而不是推断它们,为我解决了这个问题。