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.

MrTourkos
  • 1,922
  • 2
  • 18
  • 22
  • 5
    I've noticed exactly the same thing. Slow code completion since Xcode 6.3 (final). Annoying :). – sabiland Apr 13 '15 at 06:19
  • 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. – R Menke Apr 16 '15 at 02:25
  • 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 . It's faster to just manually open finder and look at the file names in that directory. – Todd Apr 16 '15 at 18:42
  • Did you open a bug report (radar) with Apple? – Léo Natan Apr 16 '15 at 22:32
  • 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. – ajeetdl Apr 17 '15 at 01:59
  • 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. – zanussi Apr 17 '15 at 21:13
  • 1
    Tested in Xcode 6.4β, still broken. – cortices Apr 19 '15 at 03:56
  • Try turn off version control in XCode preferences. – Holger Apr 19 '15 at 07:24
  • 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? – Şafak Gezer Apr 20 '15 at 07:44
  • @drowntoge One of the answers [here](http://stackoverflow.com/questions/25948024/xcode-6-with-swift-super-slow-typing-and-autocompletion) said that spotify may cause performance issues. I admit it was my last chance, but didn't do much :P – MrTourkos Apr 20 '15 at 08:25
  • @Holger Turning off either "Live issues" or Version Control made no difference. – cortices Apr 20 '15 at 09:02
  • Does holding shift when you boot Xcode help? (This suppresses all of Xcode's state restoration.) – Aaron Brager Apr 21 '15 at 02:48

5 Answers5

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:

Community
  • 1
  • 1
Yoichi Tagaya
  • 4,547
  • 2
  • 27
  • 38
  • 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! – Zen Apr 28 '15 at 17:51
  • 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. – MB_iOSDeveloper May 21 '15 at 06:42
  • 1
    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. – Terry Dec 14 '15 at 07:58
  • May have provided marginal improvement to autocomplete speed, but now I can't `po` values in the debugger area. – mkc842 Dec 24 '15 at 19:36
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.

iamandrewluca
  • 3,411
  • 1
  • 31
  • 38
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.

ChopinBrain
  • 121
  • 2
  • 14
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.
Gerd Castan
  • 6,275
  • 3
  • 44
  • 89
-2

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

joel.d
  • 1,611
  • 16
  • 21
  • I don't think so (have 6.3.1 here and same issue) – xryl669 May 11 '15 at 12:03
  • 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. – joel.d May 11 '15 at 19:41
  • Like 10s when it works (CPU usage at 100%), but most of the time it does not. – xryl669 May 12 '15 at 12:35