Xcode 6.3 code completion too slow
Asked Answered
R

5

49

I've just updated Xcode to version 6.3. I'm working on a project in Swift with some imported Objective C code. I also use Cocoapods.

I had the same issue with the Xcode 6.3 beta. I've seen and tried all other StackOverflow answers with no luck.

So far I've tried to:

  • Delete ~/Library/Developer/Xcode/DerivedData and ~/Library/Caches/com.apple.dt.Xcode with Xcode and/or Mac restart.

  • Uninstall Spotify.

  • Not use the "+" concatenation operator.

  • Set deployment's target to 8.1.

I should mention that Objective C code autocompletes fast and that before indexing Swift code too. Esc button for popup suggestions works with the same delay.

Rorke answered 11/4, 2015 at 15:26 Comment(12)
I've noticed exactly the same thing. Slow code completion since Xcode 6.3 (final). Annoying :).Claycomb
same thing here. very slow build times and code completion. Error detection is very quick to find an error (often while still typing) and then keeps hanging around. Very annoying when it keeps reporting errors that have been fixed 5 minutes ago.Hyams
I noticed the same thing, but with c++. It's practically unusable. Code completion, and any sort of variable watching popup. It also is super slow when popping up suggestions for files when I type #include <file_name>. It's faster to just manually open finder and look at the file names in that directory.Krona
Did you open a bug report (radar) with Apple?Sultry
Leo, at this point is there even any point? Bugs have been logged and developers have been complaining about these issues with Xcode and Swift for months. We are at their mercy for now. The beta for 6.3 did seem faster but really it didn't work properly in that either.Tony
Try deleting xcuserdata as well. I've seen improvements doing this. Since you are using Cocoapods, I've read elsewhere that deleting xcworkspace can help.Pluto
Tested in Xcode 6.4β, still broken.Sportswear
Try turn off version control in XCode preferences.Stenger
Having the same problem here and it's driving me nuts. Just curious, why did you think that uninstalling Spotify would help? Is there a known case about this particular program?Koral
@drowntoge One of the answers here said that spotify may cause performance issues. I admit it was my last chance, but didn't do much :PRorke
@Stenger Turning off either "Live issues" or Version Control made no difference.Sportswear
Does holding shift when you boot Xcode help? (This suppresses all of Xcode's state restoration.)Williswillison
Z
12

Setting Whole Module Optimization to Yes is a workaround in my project.

enter image description here

In my case, the project has 5 modules, named here A, B, C, D and E, where the dependency is diagramed A -> B -> C -> D, and each of A to D refers E. With Xcode 6.3 and 6.3.1, it is fine to compile modules E and D, but it takes longer to compile C, and much longer to compile B and A, like 10 mins. After I change the project setting, it takes less than a min to compile all the modules. It looks faster than compilation with Xcode 6.2.

References:

Zuber answered 24/4, 2015 at 14:17 Comment(4)
I already had this enabled for my main project but I just enabled this option on all other targets in my workspace and it seems to have sped up autocompletion. Still testing, but so far so good. Thanks!Chromatolysis
I couldn't find it easily. The "Whole Module Optimization" is located under Main Project (if more projects, the top one), 1. Target (not the AppNameTests). In the search bar type "whol" and there it is. Xcode 6.3.2.Imperceptive
Now in Xcode 7.2, this setting has changed to "Optimization Level". Just choosing "Fast, Whole Module Optimization [-O -whole-module-optimization]" for Debug boosted my code completion time.Wesla
May have provided marginal improvement to autocomplete speed, but now I can't po values in the debugger area.Scutage
C
2

Try to clear project Derived Data, after update.
Window - Projects - YourProject - Derived Data - Delete...
In my case code completion is working better after update.

Cuccuckold answered 21/4, 2015 at 16:50 Comment(0)
H
0

I used extensions on the GameScene Class and it sped everything up.

I took out three large functions from my gameScene Class, And made three separate extensions for them.

This is probably the easiest solution if none of the above work.

Hess answered 24/8, 2015 at 2:13 Comment(0)
S
0

I got code completion down from several minutes to about 2-3 seconds for my large project.

Observation: although code completion considers 'everything' in a project, code completion was extremely slow when performed in one file and very ok when performed in another file.

The property of the slow file was one expression (filling an array with data) over several 1000 lines of code.

splitting the method with this expression up into 3 methods in 2 files (not 3 expressions in 1 method), I got the code completion speed from minutes to seconds.

It appears that there is a threshold where code completion gets slow. This is not a gradual thing where code completion gets slower and slower. It is either slow or fast. You don't have to split up your code into many methods. It is enough to get under the threshold.

This behaviour suggests a constraint in resources, maybe memory. My current machine has 16 GB memory.

So this is what you do:

  • check if code completion in one file is much slower than in others.
  • look for large or complex expressions in the slow file.
  • extract parts of the large expression into one or more separate methods. Probably not many extracts necessary. Start with one.
Snafu answered 15/5, 2021 at 8:5 Comment(0)
C
-2

This issue appears to be fixed in Xcode 6.3.1 (released yesterday).

Conradconrade answered 23/4, 2015 at 2:22 Comment(3)
I don't think so (have 6.3.1 here and same issue)Botheration
Hmm, I have a project with around 50 Swift source files, and an objective c bridging header importing 15 or so external frameworks. Before 6.3.1, code completion was around 5+ seconds, and sometimes didn't happen at all. After upgrading it is less than 2 seconds, and much more reliable. I do find sometimes after adding a new class it is necessary to do a Build before code completion will work for that class.Conradconrade
Like 10s when it works (CPU usage at 100%), but most of the time it does not.Botheration

© 2022 - 2024 — McMap. All rights reserved.