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.)
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
, thePods
folder in my project directory, and<project>.xcworkspace
.I then opened terminal, navigated to my project directory, and ran
pod install
again.I experienced this same issue after upgrading to 6.1. Xcode would get stuck compiling or indexing without generating a specific error message.
The issue was finally resolved by breaking some of the longer expressions in the swift files down into multiple shorter expressions. Part of my program combines many different string variables to form a longer string. Attempts to combine them in a single expression and using the addition assignment operator both failed. I was able to make it work by doing something similar to the following (simplified):
I got this idea from receiving the following error many times in the previous Xcode version "Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions."
Hope this helps
Finally, I "solved" the issue, though it is just a workaround.
I created another project and added files one by one to it. Then I spotted a "very long" viewcontroller.swift file. Then I broke its codes into modules and made those repeatedly used codes into functions in another swift file. And also, I took the suggestion online that long expression should be broken into shorter ones. Then, the indexing works and the compiling works.
So for now, I have it "solved".
BUT, I don't think this is right. Xcode IDE should be more than capable of handling my "very long" swift file, only 1500 lines. I believe this is definitely a bug (existing for a long time), although Xcode 6.1 is already an upgrade from Xcode 6.0.1.
I am using Xcode Version 7.3 (7D175)
I think I might have figured out an underlying problem. There where two instances where I got stuck in the indexing phase:
I created a closure that I assigned to a variable and omitted the type signature. I think xcode had issues with that type inference step. If I remember correctly one of the arguments was a CGPoint, which has an overloaded constructor. My hypothesis is that there where too many possibilities of what my closure might accept as arguments.
I refactored a factory method such that instead of returning instances of one type, it could return instances of many types with a common base class. It appears that wherever I used the factory method, I had to cast the resulting object to a specific type (either with as? or by assigning it to a variable that accepts a specific type) Again the type inference step seems to be broken.
It seems like the same is going on with the dictionary declarations mentioned by earlier individuals. I filed a bug report with apple.
On my Xcode the solution was to close all redundant windows.For some reason many open windows make XCode very slow.
For me, I tried all the above with no success; but all I had to do was to delete the derived data folder, then open up another random project, wait for it to index and now my original (malfunctioning) project works!
Do the development world a favour apple and make your swift compilers open source- so we are not all thwarted by your incompetence.