XCode 8 very slow swift compiling

Ever since Swift 3 and XCode8 my project compiles quite slowly. Every time I add so much as an empty line to a file, recompiling takes a full minute. When I check the output, there is no particular file that takes very long. (I also used this tool to measure it:https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode)

It always appears to compile 4 files at once. The "rythm" is quite steady. Just very slow...

Also: Whenever I open or switch between files, it can take very long till I get autocomplete, or errors/warnings.

What things can I check? I almost feel like there is some flag I set that just drags down the build speed like crazy..

Replies

Same problem here!

Check out this thread, which has my specific suggestions and a bunch of info from other folks.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Your answer on the related thread is irrelevant to solving this issue. All your answer says it to file a bug report. Rather frustrating for you to point us to that and have the asnwer only say file a bug report...

Same here (incl xcode 8.1 beta 3)

Same here, XCTests are slower than ever. I did find that making lazy vars into Final helped by 6 seconds a test, but still not the original speed. Apple! Where is your QA?

I recently used the migration wizard to convert a 23 file application from Swift 2x to 3. The result was many warnings such as "Expression implicitly coerced from 'UIView?' to Any" .

Compile time was several minutes.


It seems any file with an error/warning is causing a re-compile of the file with the warning, even if you haven't changed/edited the file since last time you ran a compile. Having now tracked and fixed these warnings, compiling is now incremental on changed files only and down to seconds.


I don't remember seeing this behaviour in XCode 7.

I was able to greatly reduce my swift project compile times by avoiding the use the Nil-Coalescing Operator and string concatenation.


In otherwords where I had something like:


let x = "one" + object.nullableProperty ?? ""


I changed it to

let x = String(format: "one %@", object.nullableProperty ?? "")


My compile times have dropped drastically- from 20 minutes to 20 seconds.

I am so frustrated with the "tortoise" speed of swift compilations. Have ordered my team not to use swift anymore in the next projectS until Apple use it to build it's products and asked HR not to hide programmer who doesn't know obj c Until further notice. It's really funny that Apple do not use swift to build their major products, or they have insider information.


This reminds me on what happened 20 years ago when we used Microsoft Visual C++ to POC a simple dll, it took forever to compile!!!

Cheers this one realy solved my problem!