Xcode 8 recompiles every file every build

Whenever I make a change to a file, like add a new property or create a new class, Xcode recompiles every single file on a build, and it takes quite some time. I've got this happening on the GM on two different computers (one running 10.12 one running 10.11).


I've tried:

  • copying every file to a new Xcode project created in Xcode 8 GM
  • removing every "Other swift flag" flag
  • removing all third party libraries
  • comparing my project's build settings to a new project's build settings
  • remove all test targets leaving just the one target I need
  • removing all ObjC code
  • removing all ObjC related flags


Really the kicker is that moving all my code to a new project shows that it's something in my code.

Any ideas? My productivity is way down having to wait ~ 1.5 minutes for every build / auto complete / syntax highlighting to work. And yes, I've cleared derived data 🙂



UPDATE:

One more peice of information, I found this information https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160411/001693.html


which tells us about a "-driver-show-incremental" flag, which will cause queued dependancies to be listed in the build log. Sure enough I see what I think is every single swift file I have listed in the output. Trying to figure out if there's a way to make sense of what the dependancies are...


Output is something like:


...

Queuing Form.swift because of dependencies discovered later

Queuing SignInViewController.swift because of dependencies discovered later

Queuing EditProfileViewController.swift because of dependencies discovered later

Queuing ChangePasswordViewController.swift because of dependencies discovered later

Queuing JoinViewController.swift because of dependencies discovered later

...

Hi,


We still have the same problem with the new beta version of Xcode.

We have tried every possible fix (like HEADER_MAP_USES_VFS or deactivating the "Find implicit dependencies") but with no success...


I hope Apple will fix this issue because it is really slows our development 😟


Thanks.

I hope Apple will fix this issue because it is really slows our development

If the current Xcode 8.2 beta doesn’t help, I encourage you to follow the instructions I posted to this thread on 30 Sep. It seems like there is more than one underlying cause here, and good quality bug reports from folks being affected by this problem are key to resolving them all.

Share and Enjoy

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

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

I have a case with two frameworks that might be of interest. Let's call the frameworks A and B. Framework A is rather large and suffers from repeated indexing and recompiling when under development. Project B is smaller and does not suffer from these problems. If I include the large framework, A, as a subproject of the smaller framework B then the A no longer suffers from the recompiling/reindexing issue. Why this is so I do not understand.


Maybe this is a clue?


Good luck. This is a very bad problem in any case when trying to work on framework A independently of work on B.

Xcode 8.2 beta doesn’t help!

please fix this problem as soon as possible!!!

I've created a bug report with screen recording + dummy project: 29353725

Hope this will help.

We are having the same issue. Our project has few hundred Swift files. Since we upgraded to Swift3 / Xcode 8 this is happening. Even a single line change causes the entire project to build. Takes about 2-3 minutes. Our productivity has gone way down. This is not sustainable. Please help. THIS IS A VERY URGENT ISSUE.

Did you find any solution? Its Dec 2016 and problem is still there 😟

I encountered the problem when my macOS was in El Capitan. But it seems that the situation eases or even resolves after I upgraded to Sierra.

Thanks for responding and participating on this forum.


>> It seems like there is more than one underlying cause here, and good quality bug reports from folks being affected by this problem are key to resolving them all.


Even better would be some improved testing and quality control from Apple.


This bug is wasting huge amounts of time that we will never get back.


We don't all live in the vast monied lands of Apple - this is really hurting.

XCode 8.2 beta release note says.


Build System

• Xcode will not rebuild an entire target when only small changes have occurred. (28892475)

But it didn't work.


XCode 8.2 released but it still recompiles every files.


Hey, Apple developers could you focus and fix this issue?


Stop wasting our time.

Hi there,


has there been some progress with this problem? We didn't see any improvements using Xcode 8.2.


For us the problem started to manifest itself about two weeks ago: we migrated our iOS app from Swift 2.3 to Swift 3 using Xcode 8.1 (which took us about 1 week). Firstly we didn't realize what the problem was while we workend on the transition itself - probably due to having warnings and errors to fix, upgrading external frameworks, adapting code, etc. - and we believed it would all be fine when the transition was done. Unfortunatly the problem persisted even after migration finished. And continues to do so with Xcode 8.2.


We tried all kinds of suggestions in this thread and elsewhere, also in combination, but to no avail.


We have about 50K lines of code and about 30 external frameworks (integrated via CocoaPods).


The same code base before migration using Xcode 8.1/Swift 2.3 didn't have this problem. So we asked ourselves what had changed during the transition (besides code fixes, small code adaptions, we refrained from major refactorings).


One suspicious element: we moved a lot of frameworks, developed by the community, that had been integrated directly into our code base into external frameworks managed via CocoaPods (just putting the source codes directly into our code base was a mistake in the first place). Probably 1/3 of of external code was integrated directly which are now a pod framework. I can't yet confirm this yet, but I will try to undo this change and move the source code of these pods back into our own source tree and see if this makes a difference.


If that's the case, this would be a regression for code maintenance but the current situation is even worse.


This has become our main concern with Xcode and an unprecedented case of drop in productivity I've ever seen, iterative work is throttled nearly to a halt. This is a very frustating situation which I've never encountered with Xcode ever before. Feels like being back in the 90s.

I hope Apple can allocate some more smart people on tracking down this issue. For us this is more important than any new features we would see down the road.Thanks for listening,

Kaweh

Xcode 8.2 and the problem is still there - reeeaaaalllyyyyy slow compilation and incremental compilation times, with small code changes that trigger complete recompile. We are using big mixed project of Objective-C and Swift 3. It was the same way when we were using Xcode 7 and Swift 2. Reallllly slow. Please Apple developers, I hope someone is working on a fix already.

Hello everyone,


I found solution and yes it's worked for me.


I created new project in XCode 8.2 and moved all source codes from my old project to new project.

After that Xcode doesn't compile every file in single build when I change single file. Build time became ~90s to 5-6s.


I think some horrible hidden settings or something slows build time after swift 2.3 to swift 3 migration or xcode upgrade.


I hope this will help you guys,


Happy coding 🙂

Hi,


I've been folowing this thread hoping for a workaround but unfortunatelly none of the suggested solutions worked reliable. Our team has become unproductive and demotivated due to the time we have to wait compiling our mixed Obj-C and Swift project. We conveinced our management to start using Swift and now we have to keep explaining that our productivity dropped because of Swift. We are almost at the point to start writing new code in Obj-C again. We have stopped writing Unit tests and our Android colleagues are laughing at us.


We hope Apple can tackle this problem so all of us can start enjoying our jobs again.

Let me through my 5 cents in.


Our project is recently moved to Swift 3 entirely. It has containing app and the appex. It links agains several libraries managed by CocoaPods.


The relationships with Xcode 8.2, however, have never been easy...😟


1. Even after changing one characted, Xcode 8.2 builds more than one object file. The build takes 1+ minute. Every time

2. SourceKit keeps crashing, presumably bumping agains some wrong sintax in the process of wresting the iOS SDK & Swift 3 API. Without SourceKit Xcode becomes Vim, highlighting only symbols it (I think) could resolve via RegExp. It does not suggest the API, of course.

3. Every time it builds Swift libraries, why? 😠 Everytime it COPIES those binaries to the device.

4. Every time it copies some stuff to iPhone. Definatelly more than just a binary. In the same time, I am sure, Xcode knows what's alredy installed on the device. So, why waste time copying same files?

Hi Quinn,


Is there a particular toolset you recommend for the VMs?


Thanks for your help.

Is there a particular toolset you recommend for the VMs?

I use VMware Fusion for running my VMs but that’s more an accident of history than a deliberate choice (back in the day I had some friends working on that team). Unless you have other specific requirements, I suspect that any commercial product that officially supports Mac-on-Mac virtualisation would work fine for tests like this.

Mac-on-Mac virtualisation has worked really well for me. The only gotcha is that you don’t get graphics acceleration. This isn’t an issue for me (I work on low-level stuff, and thus don’t care about graphics) but I could see it being an issue for others.

Share and Enjoy

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

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

just 12 simple swift files: more than 8 minutes of compilation.


Terrible !

is there a way to moitor what a **** the compiler is doing during such amount of time ?

This just to verify wich is the main cause of this waste of time.

It might be interesting as an expiriment, if you removed from the build one file at a time and see if one file in particular is causing most of the build time. Perhaps, that might give a clue. Do that for release and debug to contrast. I'd suppose whole module optimization etc. would be off in debug. Start each run with a clean work space.


I'd wager the whole module optimization is making all the files one space and then it wants to recompile all the files even if only one file changes? Thus, the gripe. Link time optimization caused issues like this with c. So, there was the partial link time optimization as a work around -- but I'm not sure that option exists for Swift.


Perhaps ( wild guess ) it has something to do with sil? I suppose that is one difference contrasting with c's interaction with llvm? Now there is another step called sil.


Just throwing spaghetti at wall. Maybe something will stick.

Yes, the optimization is switched to "none" and it make no differences if set to "fastest".

Also isolating one file at the time does not help.


I am loooking for a way to monitor the compilation phases, but I do not know how to do it.

Hmm, when I build my workspace with two projects of 91 swift files and 7 Objective-C/C++ files on a mid 2012 MBP with ssd drive, it takes about 2:17 to compile with Xcode 8.2.1. I cleaned before I ran my test. If I build without the clean it takes about 20 seconds with signing taking most of the time.


I do not have find implicit dependencies or parallelize build checked in my schemas. ( mainly because I copy a framework )


All my project files are set to Xcode 8.0 compatible. Deplyment target iOS 10. No enable bitcode and no build active architecture only. Fast whole module optimization is on and legacy swift is off. Not a simulator build.

I have "discovered" that 7 minutes and 30 seconds on a total of 8 minutes of compilation are due to the "Signing product" phase.

My Code Signing Identity is set to "Don't Code Sign"


Any help ?

Hmm, my code signing was set to Automatic - iOS Developer . Though, if I make an archive for the store then it will be iOS Distribution. Provisioning profile is set to automatic. Code signing entitlements is blank.


Big files in your project?

No, just 12 swift source files and some hundreds of pictures to copy on the simulator.

The copy phase of the 450 pictures takes 20 seconds, while the "Signing product" takes more than 7 minutes.

Really frustrating.

Xcode 8 recompiles every file every build
 
 
Q