Ios – Xcode 8.0 Swift 3.0 slow indexing and building

indexingiosswift3xcodexcode8

I've installed Xcode 8.0 and converted Swift 2.2 to 3.0 (that process also took a lot of time, I just left my Mac running all night). I have not a big project (about 20 files). I am also using Pods. Indexing of previous Xcode version (< 8.0) worked fast but now, after upgrade, the progress bar is stuck on one position (I am already waiting for an hour).

Things I've tried that didn't help me:

  • Cleaned the DerivedData folder and restarted Xcode
  • Cleaned the project and restarted Xcode
  • Deleted Pods directory with <project>.xcworkspace and then installed again
  • Restarted Mac
  • Tried build project without Pods
  • Reinstalled Xcode
  • Tried on another Mac with cloned project

It is really not cool to make such releases of software when developers have to spend hours on solving such ridiculous problems. It is very disappointing.
Any ideas how to fix this?

Best Answer

Go to project settings, then Editor > Add Build Setting > Add User-Defined Setting, and add the following:

SWIFT_WHOLE_MODULE_OPTIMIZATION = YES

Adding this flag dropped our clean-build compile times from 7 mins to 65s for a 40KLOC swift project, miraculously. Also can confirm 2 friends have seen similar improvements on enterprise projects.

I can only assume this is some kind of bug in Xcode 8.0

Related Topic