Xcode 6.1 Swift Extensions - Sourcekit Service Crash

Xcode 6.1 Swift Extensions - SourceKit Service Crash

The SourceKit service crash error is pretty annoying and doesn't only happen with Extensions. I have found breaking your project up into different files has helped.

Xcode 6.1 swift autocomplete and code sense broken

I have had the same issue for many days while working in swift, finally I have deleted some old data in the directory ~/Library/Developer/Xcode/DerivedData and started the xcode again and error is disappeared.

Hope it helps!

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.

There's obviously many reasons why this crash can occur.

SourceKitService Consumes CPU and Grinds Xcode to a Halt

Ran into this problem with Xcode 6.1.1 earlier this afternoon (not beta, official released version). I had been running some code on Playground and was suspecting that to be the cause. CPU was pegged to nearly 100%, and Xcode was unable to complete builds.

So here's what I did:


1. Opened "Activity Monitor", which showed SourceKitService as the main CPU hog.


2. Within "Activity Monitor", double-clicked on the SourceKitService and clicked on "Open Files and Ports" section, which showed it was working on files under the /Users/myname/Library/Developer/Xcode/DerivedData/ModuleCache/ directory for a specific folder.


3. Deleted the specified folder (from a command-line, using rm -rf). The cache is regenerated based on Can I safely delete contents of Xcode Derived data folder? .


4. Using Activity Monitor again, Force-Quit SourceKitServer. Saw the now-all-too-familiar sign within Xcode saying that SourceKitService had crashed (so that's why SourceKitService sounded familiar!).


5. Repeated step 3.

The Mac is peaceful, again. No data was lost and Xcode didn't even have to be restarted (which I had tried unsuccessfully). Bottom line is that ModuleCache seems to be getting SourceKitService in a loop and deleting the folder seems to fix it. Hope this works for you too.

Bootnote:

By the way, the cause for SourceKitService issue was that I had too long an array declaration in my Swift class. I had over 200 entries in an array. Reduced it to 30 and the error went away. So the issue may have arisen due to some kind of stack overflow in apple code (pun intended).

Xcode - How to delete target in Xcode 6.1?

Just click on the .xcodeproj project file, there you still have the minus signs below the targets and can also right click > Delete

Sample Image

Xcode 6 with Swift super slow typing and autocompletion

  • Quit Xcode and restart the Mac are not required but preferred.
  • Delete the content of the folder
    ~/Library/Developer/Xcode/DerivedData
  • Delete the content ~/Library/Caches/com.apple.dt.Xcode

This is a temporally solution, but works greatly.

Below the script using Script Editor app.

tell application "Terminal"
do script "rm -frd ~/Library/Developer/Xcode/DerivedData/*"
do script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*"
end tell

Alternatively, you can create an alias for your terminal like this:

alias xcodeclean="rm -frd ~/Library/Developer/Xcode/DerivedData/* && rm -frd ~/Library/Caches/com.apple.dt.Xcode/*"

You can add that to your ~/.bash_profile and then type xcodeclean on the command line every time you would like to clear those two folders.



Related Topics



Leave a reply



Submit