Xcode Beta often crashes / high-processor SourceKitService

In some of my new projects, I have a problem that Xcode Beta5 (I had this problem with early bets too) really often freezes ("beach ball"). In the activity monitor, I see that SourceKitService requires 100% CPU. Xcode than freezes for at least 10-15 seconds.

I do not know if this is a problem with my code. In Console Utility, I see a lot of this error:

sourcekit-serv[63558]: [1:getBufferStamp:17199:1776.3650] failed to stat file: <imports> (No such file or directory)

UPDATE:

I found out that the problem is with the following: [[String: AnyObject]] , like:

 var myArray: [[String: AnyObject]] myArray = [ ["name": "item1", "children": [ "name": "child1", "children": [], "name": "child2", "children": []]], ["name": "item2", "children": [ "name": "child1", "children": [], "name": "child2", "children": []]] ] 

But ATTENTION: this code completely blocks Xcode in a few seconds!

+7
xcode swift
source share
2 answers

After I struggled with this for a while and read a lot of messages from people struggling with the same problem, I realized that the metatheme: Swift is struggling with β€œcomplex” arrays and dictionaries. To help Xcode, I explicitly defined the type of the variable for all of my arrays and dictionaries, rather than letting Xcode figure it out. It made my problems go away.

Instead of Swift determining the type of the variable by writing the following line of code:

 var myDictionary1 = ["Item":[1,2,3],"Thing":[4,5,6],"Weight":[7,8,9]] 

I rewrote my variable declarations as follows:

 var myDictionary2: [String:[Int]] = ["Item":[1,2,3],"Thing":[4,5,6],"Weight":[7,8,9]] 

As an additional note, Xcode auto-complete shows myDictionary1 as [String: ArrayInt] and myDictionary2 as [String: [Int]].

+10
source share

I found that when SourceKit is behaving badly, and I can verify that the problem is not in my code (which causes the compiler to crash behind the scenes), that giving up Xcode, removing ~ / Library / Developer / Xcode / DerivedData / ModuleCache, and also the folder in the same place with the derived data for my application often (at least temporarily) fixes the problem.

+9
source share

All Articles