Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 does full project rebuild

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?

like image 330
Vlad Avatar asked Sep 12 '16 18:09

Vlad


4 Answers

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

like image 106
Vlad Avatar answered Oct 21 '22 18:10

Vlad


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.

like image 35
Andrew Carter Avatar answered Oct 21 '22 20:10

Andrew Carter


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/

like image 21
Johnny Avatar answered Oct 21 '22 20:10

Johnny


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

like image 35
Kurt J Avatar answered Oct 21 '22 20:10

Kurt J