Xcode 8 does full project rebuild
Asked Answered
A

4

49

Having updated Swift + ObjC project to Xcode 8 (Swift 2.3) I found 50% or more of the time Xcode does a full rebuild of the project instead of an incremental build.

The changes made are adding simple print statements. There seems to be no logic as to when it performs a full rebuild.

It appears in the "Check dependencies" phase it decides this. On Xcode 7 this did not seem to be a problem.

Has anyone else encountered this?

Alkylation answered 12/9, 2016 at 18:7 Comment(3)
I'm having this problem too- currently on a google voyage to try and find out why and how to fix it, I'll let you know if I see anything. Exact same problem.Irvinirvine
Related apple forum thread: forums.developer.apple.com/thread/62737Spiritualize
I've had this issue with both Xcode 7 and Xcode 8.Ambros
A
34

I have found this works consistently, it will however compile swift files if you modify a header included in the bridging header. It will also do full compile if you switch git branches back and forth.

Firstly make sure optimization level for debug is set to None (Not whole module optimization) enter image description here enter image description here

Then, according to https://forums.developer.apple.com/thread/62737 Apple Staff (ddunbar):

We believe that setting:

HEADERMAP_USES_VFS = YES

to true in your project (or for all your targets) may be an effective workaround > for many people. This is not guaranteed to work (which is the reason it isn't > already on by default), but it should work for most projects.

This should be added through "Add user-defined setting" under your target Build Settings.

enter image description here

.

enter image description here

Alkylation answered 13/9, 2016 at 19:14 Comment(3)
actually this has been tried by several people (including me) and while initially it might look like turning on this flag helped, it actually doesn't, after a while xcode goes back to whole target re-buildAmbros
There are scenarios where xcode will need to rebuild the app fully. This fixes a know issue in xc8 where randomly xc decides to do full rebuild. As your comment above suggests you have this issue in xc7 and 8 it implies your issue is something different. You and other people may have a different dependency structure problem that causes xc to decide it needs everything rebuilt.Alkylation
Just tried that, and as far as I can tell it did the trick for me. Thanks!Dezhnev
I
12

Ok, here's an answer to why it's happening, but I don't know the solution. If you use the "Other Swift Flag" -driver-show-incremental Xcode will output what it decides it needs to compile based upon it's dependancies. You'll see things like:

Queuing EditProfileViewController.swift because of dependencies discovered later
Queuing ChangePasswordViewController.swift because of dependencies discovered later
Queuing JoinViewController.swift because of dependencies discovered later
Queuing JoinProfileViewController.swift because of dependencies discovered later
Queuing FormViewBuildable.swift because of dependencies discovered later
Queuing RadioTextFormView.swift because of dependencies discovered later
Queuing TextFieldFormView.swift because of dependencies discovered later
Queuing AccountProfileViewController.swift because of dependencies discovered later

I'm wondering if this is a swift 3 problem, because I wasn't having this issue before converting. I made a little example project where

FileA inclues a thing from FileB includes a thing from FileC

and even adding a file private change to FileC that's not used anywhere causes FileA, FileB, and FileC to be queued for compilation due to dependencies. I'm going to be testing this example in Xcode 7 later today to see what happens.

So it looks like swift 3's dependency resolution isn't working very well. I've tested this on 2 other swift 3 projects at work, and the same holds true. Make any change in any file, and every file gets compiled. It doesn't feel slow until you start getting to projects with about 15,000 lines of code or so, which may be why nobody is talking much about this. Unless you have a somewhat medium sized swift 3 app, you probably won't even notice that incremental complication isn't working quite right. I'll update if I learn anything more.

Irvinirvine answered 13/9, 2016 at 16:6 Comment(3)
Looks like this still happens in Xcode 7 with swift 2. Not really even sure what to make of this information, other than maybe the answer is simply that swift's incremental compiling still needs a lot of work...Irvinirvine
Would you be able to make your sample project available to apple in a bug report? An apple dev is asking for a sample project over on this thread that's discussing the issue: forums.developer.apple.com/thread/62737Equivocation
I need to do that, maybe I'll take the time tomorrow to put something together. I'm not sure I understand how the dependency graph is supposed to work. I read the writeup on it github.com/apple/swift/blob/master/docs/DependencyAnalysis.rst (now moved?) and I feel like it's being a little more aggressive than how it's described in that article, but it also explained of how it would lean towards adding dependancies if it wasn't totally sure. TL;DR my worry is that things are working as expected right now, and we'll have to wait for future swift versions for improvement.Irvinirvine
A
10

Apple released new beta version of Xcode yesterday (Nov 14)

Xcode 8.2 beta 2

And this issue has been marked as resolved in the release note.

Build System

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

It is working for me. The build speed came back as usual. Everybody who is facing this issue, should give it a try!

https://developer.apple.com/download/

Apotheosize answered 15/11, 2016 at 4:4 Comment(0)
B
8

Unchecking "Find Implicit Dependencies" in Edit Scheme > "Scheme" > Build tab fixed it for me for project files. "Copy swift standard libraries" still takes forever..

Bibby answered 13/11, 2016 at 23:39 Comment(2)
Hi Kurt, this solution has been mentioned many times and it can work for some people (has seemed to work for me in the past) but has a few drawbacks, one being needing to switch back and forth this flag whenever you do a full rebuild since a clean rebuild will require this to be on from what Iv seen.Alkylation
Hi Vlad, If you are only using one scheme yes you have to change it. However if you are using multiple schemes for multiple environment this is really good answer. For example i have local dev, dev, test, rc, production schemes. I am only using it on dev scheme.Folliculin

© 2022 - 2024 — McMap. All rights reserved.