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

...

Xcode 8.3.3 this issue still happen.

I just edit some code lines in a class file the xcode re-compile all source files ?


@Apple how do I help you reproduce/solve this problem plz, It's take us a lot of development time.

A completely justified rant, by someone with the scars.


Yet another year goes by, and the Xcode toolchain remains fundamentally broken.

Version 9.0 (9A235)Xcode 9: can’t type a character in a Swift source file without the entire project rebuilding. Or sourcekitservice crashing. Or sourcekitservice gobbling up all available system RAM.


I’ve done everything people recommended here and on StackOverflow over the years. Every build setting, every clearing of the cache, every script, even rebuilding projects from scratch. It’s all been for nothing.


It’s impossible to work like this. Whole days of my working month are spent waiting for Xcode to rebuild, after typing a single character in a Swift source file. The productivity is pitiful. No wonder people opt to use tech like React and Javascript for their "native" apps. Apple, you're not giving them much choice.


Year after year, Xcode gets new features added to it, and surprises are sprung on us at WWDC, but Xcode remains a basket case; a perennial Beta not suitable for production work.


What is the good of filing radars when they are ignored, and Xcode is released once a year for marketing purposes, obviously broken?

This is so incredibly poor. Xcode is not a professional development environment, and by extension, nor is iOS/macOS development. I’m sure individual engineers at Apple are committed to Xcode, but there is obviously a problem with tool leadership at the company.


Instead of adding new features to Playgrounds, how about FIXING Xcode’s most basic behaviours?


And how about a development roadmap, instead of springing major, broken releases on us once a year?


Maybe it’s time to open source the toolchain, ala Swift? It’s not like Xcode has any great business advantage for Apple right now.

Maybe Xcode should be forced through the same App Store review process we go through?


Grrr.

I was able to resolve this issue by adjusting settings in the build phases for my target.


We were using a custom script build phase step to insert preprocessing flags into one our cocoapod depedencies. Changing that .xcconfig file caused our project to re-compile on every build or run.

Checking the box ' Run script only when installing' underneath the script editor in the build phase step solved the issue immediately for us.


PROJECT SETTINGS > BUILD PHASES > (custom script) > click 'Run script only when installing'


Now I have my productivity back!!



Note: You may not have a custom script but I would inspect all of phases in case one is touching the config files for either your project or your dependencies.

I filed a radar for the original issue with the -driver-show-incremental setting crashing Xcode. I'm pretty confident at this point that the dependency graph is the source of our troubles with very long build times in Xcode (still in the latest 9.0 and 9.1), but without this flag working I'm not sure what options we have to troubleshoot.


rdar://35128994

Just adding to the pile, I miss objective-c.

I've tried all the suggestions uptill now, My compilation time is 2 minutes, when my project was pure objective-c, compile time was less than 20 seconds.

I feel my hair graying with each 6 minute build! And I regret using Swift everytime I see the "Compiling Swift files" when all I'm doing is running another set of tests without changes to the source files...

Hi,


So, out the window almost 2020. The problem is still not solved.

Xcode 8 recompiles every file every build
 
 
Q