Swift Xcode Index Freezing or Slow

leonard picture leonard · Oct 21, 2014 · Viewed 45.9k times · Source

Maybe this is just me experiencing such an annoying "feature":

After upgrading from Xcode 6.0.1 to Xcode 6.1, things changed. Xcode 6.1 is forever indexing the project or compiling source files. The project is not a huge one. It just contains a bunch of Swift files and AWS SDK 2.0 Cocoapods in the workspace. I don't think it should prevent the whole to index and compile smoothly. I tried with some aws-sdk-ios-samples, just to see how Xcode 6.1 works on them, and it ended up in the same forever waiting.

What solutions I have tried so far:

  1. Deleting "Derived Data" in the Organizer, and re-open and workspace. (fail to fix)
  2. "Show Package Contents" on the .xcodeproj file and deleting .xcworkspace as in (Xcode 4 - slow performance)

None of them worked, unfortunately.

P.S. maybe I should try re-creating the project? My computer settings: MacBook Pro (Retina, 13-inch, Mid 2014), Memory 8 GB 1600 MHz DDR3, with Yosemite. (I think this is enough for running this small project.)

Answer

Zen picture Zen · Dec 17, 2014

I tried many of the suggestions above including splitting files, installing Xcode 6.2 beta, and breaking string concatenation statements. What finally did it for me was splitting an array of dictionaries literal declaration I was using for test data into multiple .append statements.

// This causes indexing/building to hang...
var test = [ [ "a": false, "b": "c" ],
             [ "a": false, "b": "c" ],
             [ "a": false, "b": "c" ],
             [ "a": false, "b": "c" ],
             [ "a": false, "b": "c" ],
             [ "a": false, "b": "c" ] ]

// This works fine.
var test = [ [ "a": false, "b": "c" ] ]
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])

Also, for what it's worth, the 6th entry in this array is what causes the issue for me; five works just fine.