Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SourceKitService Terminated

The answer to mine (Xcode6-Beta7) was simply to delete the Derived Data folder.

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.


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.


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 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.

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.

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.

  1. Open your project and change the target's deployment target to something <= 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)

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


You just need to delete the "ModuleCache", this is some kind of cache used by Xcode for Autocompletion.

Copy and paste the following line in the Terminal:

rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache


SourceKitService crashes on my system as soon as I type

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.

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 {

}

It started happening on my spritekit project after inserting the touchesMoved-function. This function uses forced unwrapping, which seems to cause the problem:

override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!)

After removing the exclamation marks and thus stopping forced unwrapping, the SourceKitService stopped crashing.

Hope this helps!


I found a solution on Apple's Developer Forums (which requires login, so I'll explain it here too).

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".

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.parto on July 10, 2014


Use other name than Swift for the project. "Swift" is reserved.