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

...

Post not yet marked as solved Up vote post of aandrewc Down vote post of aandrewc
83k views

Replies

@Ewam Just would like to make sure that this issue is being worked on by your team. It seems to affect a bunch of people. I see two stackoverflow questions about it, one including a 500 points bounty: http://stackoverflow.com/questions/39456223/xcode-8-does-full-project-rebuild and http://stackoverflow.com/questions/39588223/xcode-8-recompiling-complete-code-everytime.


It still happens with Xcode 8.1, even when there is no change at all. I'm willing to share my app's source code privately if it can help investigate the issue. I tried to create a sample project but wasn't able to reproduce. Can you let us know what we can do to help investigate and/or escalate? Happy to help.


To give you an idea of how annoying it is: every time I make a change, or really any time I build my app – even without a change –, the entire project is recompiled. It means my feedback cycle is up to 10 minutes instead of ~30 seconds. It is totally impossible for me to work under those conditions.


In the meantime, I'll try the workaround here: http://stackoverflow.com/a/39704001/646960 and keep this thread updated.


Edit: The following workaround works great. As mentionned, you need to uncheck it only after the first build.


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

@Ewam any update? A simple change results in needing to wait 5-10 minutes for the project to compile, making writing new stuff difficult and debugging essentially impossible.


Any known workarounds or temporary fixes? Our iOS team spends close to half of every day waiting for the compiler and it's been like this for a week at least.

Bump! Same frustration here. 😕

Just curious, probably not a fix, in the LLVM Code Generation settings, is Link Time Optimization set to off or Incremental ? I think Monolithic would build all the files again. And Incremental would limit the scope of files that would need to be recompiled to files that changed and or files that are tangentially related to the optimization of a particular file that changed. My assumption is the Clang or Swift compiler feeds LLVM which creates the final machine code.(?) Not sure how that would relate to whole file optimization in the Swift settings -- would not be surprised if that triggers more compiles too.

Same problem here; It's frustrating

Same here, Bump!

Folks, if this issue is causing you serious grief — and it sounds like that’s the case for many of you — then you need to file a bug about it. My recommendation:

  1. Find a project that reproduces the issue and that you’re willing to share. If you’re not willing to share you real project, see if you can reproduce the problem with some other project, like something open source.

  2. Make sure the problem reproduces in a clean environment. In situations like this, I generally use a VM. I set up a fresh VM, install Xcode, then take a snapshot. I then try reproducing the problem, reverting to the snapshot if things get confused.

  3. Once you have a clear set steps worked out, file a bug report with those step and attach your project.

Please post your bug number, just for the record.

Step 2 sounds like a bunch of work but it’s really important. It’s possible that there’s something about your environment that’s triggering the problem; if so, this step will show you that (because the problem won’t reproduce in the clean environment), or give you the confidence to file a bug saying that this is a general issue.

On a personal note, I have to say that I haven’t seen the problem myself, so I don’t have any advice to offer. However, the fact that I haven’t seen it doesn’t mean much; I generally work on small sample code projects, and I wouldn’t notice this problem even if it did crop up.

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"
  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 workaround works great.


One thing I notice is that I have to do a clean before the first build, otherwise won't work. After first build, uncheck "Find implicit dependencies". The following 10 builds take no more than 30s 😉 . Unfortunately, after about 10 builds, it will start recompiling all swift files. Not sure if some changes I made trigger recompile or something else.

Same situation here.


I'm not 100% sure of that, but I have two targets in my projects: "PROJECT" and "PROJECT DEV"


The two targets are using the exact same 268 source files, I checked the build settings one line at a time and they are all identical. "PROJECT DEV" target is the one that take 3 minutes at every single build, no matter if I modify a file or not.


Surprisingly, the "PROJECT" target is working normally, takes 5/10 seconds to compile, wether or not there is a small modification to compile.


Maybe I'm wrong, but I'm really wondering if the space in the target name couldn't be the cause, what are your target names guys?


(configuration: Xcode 8.0 8A218a, Swift 2.3, CocoaPods 1.0.1)

Guys I have created radar for this issue. In my case we use only Objective C/C++, no swift code here. I have reported this when xCode is beta, but because issue appearing randomly I reported that after removing scripts issue resolved, but it isn't.

Just wondering, what is everyone running?

I'm on Xcode 8 and El Capitan

I have the same issue on Sierra.

Our project dosn't containing any swift code, but we also encounter this problem. Is there any ways to see what causes project to be full rebuilt, something like

-driver-show-incremental for Objective-C projects.

This issue become more worse and worse after upgrade to Xcode 8 and Swift 2.3. Now everytime need full build even just add a comment inside a function!!

I've solved it in my project.


Go into your target's build settings and change the C Language Dialect to Compiler Default


Sources:

1. http://stackoverflow.com/questions/39588223/xcode-8-recompiling-complete-code-everytime/39874030#39874030(my bounty!)

2. http://stackoverflow.com/questions/36438919/xcode-7-3-library-project-compiles-every-time

3. https://forums.developer.apple.com/thread/44406



EDIT: I was wrong. Back to compiling everything again. I can't work like this.