Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8.3 Indexing & Building Extremely Slow

Tags:

I am posting this after reading many similar posts on here regarding this issue and none of the solutions that worked for other people not working...

  • Xcode Version 8.3.3 (8E3004b)

  • Swift 3.1


Things I tried

  • Deleting Derived Data folder
  • Deleting Workspace File
  • Cleaning Build Folder
  • Cleaning Build
  • Reinstalled Xcode (after complete removal)

I also looked for Swift Issues:

  • Removed all concatenating strings
  • Cleaned up Swift arrays and dictionaries
  • Added Whole module optimizations

This all started happening after last Xcode update of 8.3.3. My project was compiling within seconds and now I have to wait at least 15 mins for it to index, then 5 minutes to compile after everything I change even something small in code.

When Building, it get stuck in "Compiling Swift source files". Is there way for me to look in to where it is actually getting stuck?

BIG UPDATE

I tried pretty much everything. Read every article, post, ect. NOTHING worked. My project was created right after 10.0.

Solution Creating a new project and copying each file worked! It used to take 8-9 minuted to build. Now less than 2 seconds!

like image 419
Gizmodo Avatar asked Jul 24 '17 17:07

Gizmodo


2 Answers

Apple knows about this problem, and says that Xcode 9 beta will perform much better. Note that if you don't want to update to Swift 4, you can continue compiling in Swift 3 mode using Xcode 9. The big limitation is that you won't be able to submit your project to the App Store until Xcode 9 goes final.

Also, Xcode 9 contains a new build system. You don't get it by default: you have to turn it on for this project. Choose File > Project Settings and switch the pop-up menu to New Build System (Preview). This is experimental, but it will be the default build system eventually, so it would be interesting to know whether this makes an appreciable difference.

If you don't want to update to Xcode 9 beta, you will just have to do a binary search: comment out all your code and start adding it back, piece by piece, until you find that piece that's causing the trouble.

like image 69
matt Avatar answered Oct 04 '22 15:10

matt


The best way to work this out is to find what out what the build is doing while compiling your code. This is a really useful tool to use: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode

When you run this tool it will show you what methods are taking the longest to compile, and then you fix those. Once you have done that, you can also try the answer I gave here to decrease the build times: Extremely long compilation times with Swift in Xcode

like image 26
totiDev Avatar answered Oct 04 '22 15:10

totiDev