1 2 3 4 5 Previous Next 127 Replies
      Latest reply on Jan 23, 2018 1:57 PM by mahboud Go to original post
      • 30. Re: Xcode 8 recompiles every file every build
        adamwaite Level 1 Level 1 (0 points)

        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.

        • 31. Re: Xcode 8 recompiles every file every build
          robseward Level 1 Level 1 (0 points)

          This didn't work for me – as soon as I made a change to the code it started recompiling from scratch again.

          • 32. Re: Xcode 8 recompiles every file every build
            andyyhope Level 1 Level 1 (0 points)

            Reported

            Radar: 28645028

            • 33. Re: Xcode 8 recompiles every file every build
              andyyhope Level 1 Level 1 (0 points)

              I couldnt find the Dialect flag in Xcode?

              • 34. Re: Xcode 8 recompiles every file every build
                aandrewc Level 1 Level 1 (0 points)

                Sorry for dragging my feet, I need to take the time to make an example project, but I haven't done so yet.

                 

                To add some more information on what I think may be happening in my current project I can't share...

                 

                After reading https://github.com/apple/swift/blob/master/docs/DependencyAnalysis.rst  I'm scared that things are actually working as expected. The line "If there's not enough context to decide, the compiler has to go with the conservative choice and record it as cascading." I think is the heart of the problem. All of my coworkers projects (about 5 I've checked with) have this issue. The projects that are relativley new and small seem to not have a problem, simply becuase there's not a lot of files so recompiling every time doesn't manfest itself as a noticiable issue. But for the projects that are of any size or further along in development, we're hitting 30 seconds - 3 minutes incremental builds.

                 

                Here's an example of how I think the dependnecys get out of hand. I make a change in my root view controller, which holds my tab bar controller, which holds my 5 main feature controllers, which hold their detail controllers, etc. The change in the root view controller is, I *think*, a non cascading change, but the compiler can't figure out if it's non cascading or not, so it's marked as cascading. This means that it needs to recompile the tab bar, feature controllers, detail controllers, etc, because it just can't know for sure that a non cascading change has been made to any of those. Then you get into it needing to recompile all those controller's dependacnies, and now you have a 1 minute incrementail build even though you may have just added a private function that nobody even uses to a controller.

                 

                It's hard to notice this issue when you're working on a toy project, but once you're working on a "real" scale application it becomes very apparent. I'm scared that there's a very small amount of developers out there making "real" sized apps in 100% swift at the moment, so it's a realitivly quiet problem. A lot of established apps are just adding newer features in swift, so they don't have the issue yet, but as we start moving towards more swift code in older projects, or more swift first apps, this will become a much more real issue.

                 

                Sorry for rambling a bit, just wanted to get my thoughts out!

                • 35. Re: Xcode 8 recompiles every file every build
                  LeFancy42 Level 1 Level 1 (0 points)

                  Xcode8 and Sierra.

                  It's horrible.

                  • 36. Re: Xcode 8 recompiles every file every build
                    LeFancy42 Level 1 Level 1 (0 points)

                    Before finding this thread I started a discussion on Stackoverflow.

                    One guy seems to be on to something by changing the optimization flag of your code.

                    His and my project seem to compile faster when you turn on Whole Module Optimization.

                    Quite counter intuitive, but I can reproduce it.

                     

                    Check it out here:

                    http://stackoverflow.com/questions/39879979/xcode-8-very-slow-swift-compiling/39949519#39949519

                     

                     

                    EDIT:

                    It appears that the answer I was referring to has been deleted, sorry.

                    • 37. Re: Xcode 8 recompiles every file every build
                      Christopher Rogers Level 1 Level 1 (0 points)

                      Your milage may vary, but I seem to have had success with this by getting rid of a lot of the imports in my prefix header. (I tried to get rid of it completely but it's too daunting of a task right now.)

                       

                      Peeking into the ModuleCache directory, it seemed like Xcode was coming up with way too many configurations where it needed to create a new ModuleCache entryfor  all the modules (and precompiled prefix headers), so from there I started trimming down the imports in my prefix header for the mean time (since I couldn't just delete the prefix header entirely), which seems to have alleviated the problem.

                       

                      I wrote up all the details here:

                      http://stackoverflow.com/questions/39588223/xcode-8-recompiling-complete-code-everytime/39976395#39976395

                       

                      Hopefully this helps someone out there.

                      • 38. Re: Xcode 8 recompiles every file every build
                        joshwright Level 1 Level 1 (0 points)

                        Bump.

                         

                        Been over a month and nothing... anyone able to find a fix? Working like this is miserable. The scheme trick ocasionally works but only for a couple of builds.

                        • 39. Re: Xcode 8 recompiles every file every build
                          Ankit8946 Level 1 Level 1 (0 points)

                          This is driving us cray... We are a 4 member team and we spent almost 80% of our time waiting for the xcode to compile.

                          This has to be the worst bug in xcode history.

                          • 40. Re: Xcode 8 recompiles every file every build
                            eskimo Apple Staff Apple Staff (12,095 points)

                            … we spent almost 80% of our time waiting for the xcode to compile.

                            Yowsers!  Presumably you filed a bug about this.  What’s the number?

                            Share and Enjoy

                            Quinn “The Eskimo!”
                            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                            let myEmail = "eskimo" + "1" + "@apple.com"

                            • 41. Re: Xcode 8 recompiles every file every build
                              IvanD Level 1 Level 1 (0 points)

                              I also have this problem and it's driving me nuts.

                              From a reddit discussion somebody tipped me about this obscure Xcode 8 defaults setting:

                              defaults write com.apple.dt.Xcode ExplainWhyBuildCommandsAreRun -bool true

                               

                              Paste in Terminal and restart Xcode.

                              The name is self-explainatory - it generates debug output when building, explaining why.

                               

                              Then when building you can check "Build target XXX" -> "Compile Swift source files" in the Report Navigator

                              The issue seems to be "(running because command line arguments are different from the last time)"

                               

                              This hasn't solved my problem, but at least is pointing somewhere.

                               

                              My rdar is

                              28501724 marked as a duplicate of 28292226

                              • 42. Re: Xcode 8 recompiles every file every build
                                0x5f3759df Level 1 Level 1 (0 points)

                                Thanks IvanD,

                                 

                                I did try your suggestion and I am also getting the "(running because command line arguments are different from the last time)" message when the problem occurs [I can get Xcode to recompile the entire project by just touching a single swift file without making any changes].

                                 

                                I did capture the different arguments and have filed a bug report (28799303).

                                • 43. Re: Xcode 8 recompiles every file every build
                                  ldiqual Level 1 Level 1 (0 points)

                                  This is a great bit of information. I ran

                                   

                                  defaults write com.apple.dt.Xcode ExplainWhyBuildCommandsAreRun -bool true
                                  

                                   

                                  Then built my app twice (making sure the second build wasn't incremental), and I extracted the two argument list.

                                   

                                  Ran this command:

                                   

                                  wdiff arg1.txt arg2.txt | colordiff
                                  

                                   

                                  Here's what I get:

                                   

                                  [-Internal-all-target-headers.hmap-] {+Internal-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /DerivedData/App/Build/Intermediates/App.build/all-product-headers.yaml+}
                                  

                                   

                                  So it seems that between builds a combination of the following params gets added/deleted:

                                   

                                  Internal-all-target-headers.hmap
                                  Internal-all-non-framework-target-headers.hmap
                                  -Xcc -ivfsoverlay
                                  -Xcc ../DerivedData/App/Build/Intermediates/App.build/all-product-headers.yaml
                                  

                                   

                                  I'm not too sure what those arguments are, maybe someone at Apple can clarify this for us?

                                  • 44. Re: Xcode 8 recompiles every file every build
                                    eskimo Apple Staff Apple Staff (12,095 points)

                                    28501724 marked as a duplicate of 28292226

                                    Thank you for both filing a bug and posting the bug number here.

                                    The bug yours was duplicated to (r. 28292226) is being actively investigated.  There’s no fix in the current (Xcode 8.1 beta 3, build 8T47) but please check back in when we release anything later than that.

                                    Share and Enjoy

                                    Quinn “The Eskimo!”
                                    Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                                    let myEmail = "eskimo" + "1" + "@apple.com"

                                    1 2 3 4 5 Previous Next