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

...

I added as a User-Defined Setting in my Project Build Settings and it seems to be helping.


Update: It seemed to help for a few builds then my project started recompiling all files on even single line changes.

This issue is also causing us a lot of wated times.

For us, the incremental builds are working only if we change something INSIDE a function.

Incremental builds don't work if we:

1) change a function name

2) add a new class

3) add a new var to a class


I have filed RADAR

28848000


Which contain a small swift project with 2 classes, unrelated to each other to show the problem.

  1. Go to Product -> Scheme -> Edit Scheme. Select Build in left side column and uncheck "Find implicit dependencies"
  2. But this flag should remain checked when you are building the project for first time.


This worked for me. It no longer recompiles the entire project. The only side effect I have noticed so far is that I have to turn it back on for the first build if i clean the project and/or purge DerivedData.

I haven't been able to replicate this issue in a new dummy project, that I would be able to share. I have noticed it only in larger project for customers, all of which have started as Xcode 7.x projects with a bunch of Cocoapods dependencies.

This didn't change anything for us. Even with this flag on, changing a single line of code results in a non-incremental build (about 7 minutes). The current situation is getting us in big trouble holding an important deadline and lets us reconsider our decision for using Swift in future projects. I've been an early adopter working with Swift since 1.0 and was a big fan but this experience destroys my trust in Swift. How can we be sure that such a show stopper issue won't happen in future anymore. I think a big part of the problem is that Apple doesn't eat it's own dog food (e.g. like eskimo wrote "I generally work on small sample code projects and I wouldn’t notice this problem even if it did crop up.").

Hi ddunbar,


Your workaround seems to work for bug 28799303.


Without your workaround we can easily reproduce the bug, but with your workaround we haven't had the compilation issue for two business days and we haven't been able to reproduce it since then.


Many thanks. Hope the issue will be solved soon.

Filed one more bug (28908050) with small example project there.


Simply adding/removing ": Equatable" to a separate class that is not related to any others triggers full rebuild in my case.

The issue still persist in the Xcode 8.1 GM.

it recompiles everything due to " (running because command line arguments are different from the last time)"

"Find implicit dependencies" continues to be the solution (don't forget to turn it back on after a project clean).

This setting fixed my issue with whole target recompilation. Thanks for help, but I'm expecting for this issue to be fixed in a future xcode 8.1 release without any custom setting configuration required

Can you tell me where to set the setting: HEADERMAP_USES_VFS = YES, thanks in advance .

.

At Build Settings, find the + button (top left after Levels filter). Tap this and add HEADERMAP_USES_VFS as Key and YES as value.

Thanks. After a few days of attemption with the setting, the situation improve a lot , but sometimes some modify also can cause Xcode recompiling all file source. The answer not the best and final solution.

This seems to help me as well, even if from time to time it doesn't seem to work. Anyway a huge improvement.

I'm still seeing this problem with Xcode 8.1 and even after adding aforementioned build settings. I've filled 28998073 for this, hopefully folks at Apple will take a look soon as this has seriously affected performance of our team.

Hello,

Our team is still having those issues too.

You can't imagine the daily frustration of having to wait 5 minutes for the project to compile just because I changed 4 lines of code (or less) ...

Sadly I can't share the sourcecode of the project ... did somebody provide that so you can investigate ?

thanks and good luck!

Same Problem for object-C! It will waste about 10 min to compile 850 files everytime.....

Add USer-Defined Setting "SWIFT_WHOLE_MODULE_OPTIMIZATION = YES "" in your Project Building Settings may help you, But every time build have to spend about 120s

After filing a radar back in Swift 1.0 that was resolved in 1.2 with the incremental compilation I'm sad to see this is back i.e. regression


A colleague reported this earlier this week with an existing project (~35,000 loc)so I did a test with a brand new Xcode 8 project: https://github.com/madhikarma/incremental-compile-demo


What I noticed here is that the second compilation without any changes it compiles significantly faster though ttheh logs show all files being evaluated still which didn't happen before.


When we do make a change to code e.g. a private method then a compilation that takes longer but not full clean compile


Using HEADER_MAP_USES_VFS or deactiving the "Find implicit dependencies" setting in the scheme seem to help a little but not got


Without pre-compiling and linking Pod based libraries (going to this next) as Dynamic Frameworks instead I spent 1.5 days "optimzing" the app codebase to make it quicker to compile (down from 90 secs to 61 secs) via targeting the slow compiling files because of how often full recompilation is likely to occur.


It's going to be a big productivity drain and we have quite a few Swift projects either now on 2.3 or 3.0 that are of similar size (~35,000 lines of code)


Hoping the radars are resolved in time for Xcode 8.2...

i found a solution that works on my computer.

Before building restart Xcode. It compile only the needed files.

If you dont close xcode, it will try to compile the whole thing again.

Not only Swift, but my Objective-C project has same issue. Sometimes like add a NSLog into singleton object's method or edit storyboard file for just change a boolean properity to a view will cause whole project to recompille.

This popped up after updating to Sierra and xCode 8.1.


Absolutely brutal.. better hope you write it correct the first time!

It's crazy, but this worked for me: go to keychain access and delete your certificates with search "com.apple.idms.appleid". I only had one, but the source is from here: https://forums.developer.apple.com/thread/67063 and they had a ton.


EDIT: nevermind, its back..

Exaactly same situation here.

I just downloaded Xcode 8.2 Beta, I saw the next thing in the release notes: "Xcode will not rebuild an entire target when only small changes have occurred. (28892475)" but still is happening for me. Is this beta fixing the problem for someone at least?, we are a team of more than 10 developers and we are all suffering this painful issue. It's not serious...

Todays' Xcode 8.2 b3 build 8C30a's release notes claim this is fixed.

Xcode 8.2 Beta 2 haven't solve this problem either.


Sad.

Xcode 8 recompiles every file every build
 
 
Q