Incremental compilation, dependencies

Xcode likes to rebuild the whole target every time I change a method signature or introduce new functions in a single file. After reaching 250K+ lines of Swift code this became a problem.


I'm trying to debug it using the "-driver-show-incremental" flag.

There is a file A.swift which defines a class and some structures that are used somewhere in the project. I modify one method signature in that class (the method isn't used anywhere, just for testing). The compiler output contains lots of "Queuing because of dependencies discovered later". Some of them make sense (the files that use the A.swift directly). But there are more entries like this:

Queuing because of dependencies discovered later: {compile: F.o <= F.swift}
  A.swift provides top-level name '=='


There is indeed a structure in the A.swift that conforms to Equatable, and thus provides a static '==' function. However, the F.swift doesn't reference A.swift at all. In fact, the F.swift doesn't have any internal dependencies, it's just some helper extensions on UIKit and Foundation classes.


There must be some language feature I use that causes this behaviour, but I can't think of any.


Edit:

.swiftdeps files make it obvious that '==' is what causes almost all the files in the target to be rebuilt. It is stated that A.swift provides a top-level '==' symbol and, well, lots of files do use the '==' operator.

The only workaround I can think of would be to refactor all the types that make use of Equatable and other similar protocols into their own files. I'm not sure if doing that on a 250K LOC codebase would be faster than waiting for 6 minutes on every method signature change though.

I think you might have better luck with this question over on the swift-users mailing list.

Share and Enjoy

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

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

you don't need to use xcode to build an app but you must have it installed.


tools like fastlane, or poke around github at what facebook/google have for managing massive builds

Incremental compilation, dependencies
 
 
Q