Swift Xcode Index Freezing or Slow
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:
- Deleting "Derived Data" in the Organizer, and re-open and workspace. (fail to fix)
- "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.)
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.
The only working solution for me is to delete all the derived data (not only for the current project, just clean up the whole folder) and then restart Xcode.
Open File / Preferences in Xcode
Click on Locations on the far right of the pop up window
Click on the little arrow icon next to "/Users/Mac/Library/Developer/Xcode/DerivedData"....it takes you to an Xcode folder that contains a DerivedData folder (that contains all of the derived data from your previous projects.)
DELETE the DerivedData folder
Are you using CocoaPods? I ran across the same issue earlier today. (Using xCode 6.1.1)
To fix the issue, I deleted everything in ~/Library/Developer/Xcode/DerivedData
, the Pods
folder in my project directory, and <project>.xcworkspace
.
I then opened terminal, navigated to my project directory, and ran pod install
again.
Had the same issue today. Xcode 6.3.2, medium-sized Swift project. At one point it started indexing and it would never finish indexing. The code that caused this was a dictionary of type [String:[String]], so a string-key dict with string arrays as values. I had two of these with keys from A to Z and each of these 26 entries contain a string array with 5 to 10 strings.
Clearing derived data didn't help. Only commenting out those dicts made it go again.
Honestly, this is ridiculous! Apple needs to fix Xcode! It's already horribly slow when compiling Swift projects but bugs like this are a showstopper. I can't do my job properly with this!