With any change in code (though file is not in .pch), complete project recompiles every time.
-
33Why is this downvoted?! This is a legit issue. Takes 4 minutes to compile every time, nuked all team productivity.– JoshCommented Sep 20, 2016 at 21:01
-
1I too get this issue.– AJ9Commented Sep 22, 2016 at 10:57
-
3Are you modifying xib/storyboards with some IBDesignable stuff?– LarmeCommented Sep 26, 2016 at 13:25
-
1Related apple forum thread: forums.developer.apple.com/thread/62737. No workaround still.– ldiqualCommented Sep 29, 2016 at 19:28
-
1Make sure to open a bug report, as suggested in the Apple forum.– Léo NatanCommented Sep 30, 2016 at 16:30
15 Answers
Update 2017/1/2
This issue has not been resolved at Xcode 8.2.1 (for my project)
How to survive?
Code IDE: Xcode/Atom
Build: xcrun
Debug: Xcode (Control + Command + R)
Update 2016/12/17
This issue has not been resolved at Xcode 8.2.
Update 2016/12/12
Atom to code and command line to build and debug is my choice now. Hope Apple will fix this legit bug soon.
Update 2016/12/04
This issue seem resolved with Xcode 8.2 (beta 2).
But for me its not be resolved, i face this issue even when i use Xcode 8.2. You can give it a try (download Xcode8.2 beta2 here)
Build System • Xcode will not rebuild an entire target when only small changes have occurred. (28892475)
Old answer: This is a work around:
"Build Setting" tab -> "C Language Dialect" -> Change it to "Compiler Default".
The "C Language Dialect" was set to "GNU99" instead of "Compiler Default". Previously the standard was GNU99 but now its not. At some point Xcode did not migrate the library project settings correctly and so it was set to GNU99. Once I changed it to GNU99 it stopped recompiling all my code every time !
-
1So far so good!!! Give me one hour and the bounty's yours if it keeps up. Commented Oct 5, 2016 at 14:31
-
7
-
1I have the same behavior. If I clear the derived data (or change the C language dialect) it'll work for about 10 builds. After that it falls back to rebuild everything. Commented Oct 10, 2016 at 2:58
-
1Xcode 8.2 (beta 2) works for 10 builds then rebuilds everything from scratch, but still better than previous one.– MarkusCommented Dec 15, 2016 at 12:52
-
3Unfortunately the issue persists in Xcode 8.3 beta 2 (at least for us). No noticeable improvement can be measured in our project. Commented Feb 10, 2017 at 12:04
Go to Product -> Scheme -> Edit Scheme. Select Build in left side column and uncheck "Find implicit dependencies"
But this flag should remain checked when you are building the project for first time..
-
@Josh, are you using multiple projects within your project (eg. subproject or included). And are you sure by looking at your build output that it is truly rebuilding everything? Commented Sep 30, 2016 at 18:50
-
3Its a basic workspace with cocoapods and the main project. CocoaPods stays built, but the main project rebuilds every file; watching the build output and its definitely all 100+ files rebuilding.– JoshCommented Sep 30, 2016 at 19:06
-
1Update: it seems this solution works for a few builds after doing so, however so does cleaning the entire project and rebuilding. By the 2-8th time rebuilding however, it starts recompiling everything again. Any ideas? Beyond frustrating.– JoshCommented Sep 30, 2016 at 23:22
-
This does not work, at least not with a CocoaPods workspace. Everything builds, every time. Super annoying, especially since Apple have had years to fix this issue.– WombleCommented May 20, 2018 at 23:52
Fix for me was just closing storyboard, I had the source file opened with the assisted editor and the storyboard file opened as well (closing the storyboard --- since I wasn't making any changes to it) removed all the unnecessary compiling
-
1
UPDATED
The single biggest improvement I was able to make was modularizing my project. Specifically modularizing the ORM layer which is used in almost every other class. By moving that code into a separate target within my project and importing it as a module I was able to greatly improve compilation times. No longer does Xcode decide to recompile unnecessary files when I do a build.
Now I use the Single File compilation method for fast incremental debug builds.
There are some other good suggestions in this link including code refactoring, https://medium.com/rocket-fuel/optimizing-build-times-in-swift-4-dc493b1cc5f5
OLD
Still has been a constant issue for me with Xcode 9. Like many of you I'm working on a large swift 4/cocoapods project with many source files and re-compiling every file every time is infuriating.
So far I'm getting the best results with the following settings. I suggest you give it a try and see how it works for you.
- Schema -> Build -> "Find Implicit Dependencies" = TRUE
- Build Settings -> Link-Time Optimization = Incremental
- Build Settings -> Optimization Level (Debug) = None [-OO]
- Build Settings -> Optimization Level (Release) = Fastest, Smallest [-Os]
- Build Settings -> Increase Sharing of Precompiled Headers = YES
- Build Settings -> Enable Incremental Distill = YES
Added custom User-Defined build settings,
- Build Settings -> HEADERMAP_USERS_VFS = YES
Note: I do not have the custom user-defined setting for whole module optimization.
I changed a few things with my code regarding the prefix header that seem to have fixed this problem. I don't know which one actually did the trick, but I'll share them all in hopes that it helps someone else out there. If you don't have a prefix header set, then I guess this isn't the problem (or the problem is multifaceted).
- Remove any imports from the prefix header that are files from the built products directory so you can change the build setting for this ("Precompiled Header Uses Files From Build Directory") to "No". Be sure it is not indirectly imported through other imports as well.
- Remove any imports from the prefix header that use Clang modules (libraries or frameworks that have a module.modulemap file in their Headers directory, so you can write code like
@import MyModule). (For me, this and step 1 were one and the same.) - Set the build setting for prefix header sharing to "Yes". (I don't think this is necessary, and it shouldn't have any effect in my own project. I'm just stating this because I changed it because I was willing to try anything. :))
- Exit Xcode and delete your DerivedData/ModuleCache directory (configured to be at ~/Library/Developer if I remember correctly).
If that still doesn't work, you can try removing some more imports from your prefix header. There may be something tripping it up...
Looks like they are actively working on it according to https://forums.developer.apple.com/thread/62737 but a workaround is to add
HEADERMAP_USES_VFS = YES
under the build settings of your target (Project -> Target -> Build Settings -> User Defined).
This solution worked every time for me today, after no other solution working consistently for the past month.
EDIT: Still sometimes recompiling everything, although it seems to do it much less frequently with this setting defined.
-
I've also added this value, the build time is faster but it didn't solve the incremental build. I've changed the Swift Compiler - Code Generation / Debug to Fast, Whole Module Optimization ... is the best result up to now Commented Oct 25, 2016 at 17:14
-
-
2
-
1if you don't see it then read this meandmark.com/blog/2011/03/xcode-4-accessing-build-settings Commented Nov 29, 2016 at 7:37
Check out all of your code on @IBDesignable directives in my particular case Xcode build project all of the time because I had some views on my storyboard that was contain this @IBDesignable attributes in it.
Second thing is that I also have my storyboard opened in separate window (not tab) that is push my Xcode make builds for all of simulators forever.
-
We use quite a number of
@IBDesignabledirectives... is there anything in particular that we should look for?– StanCommented Aug 21, 2017 at 20:48 -
I think that it's possible to find them by excluding one by one, and check result, my case it was only 2 of @IBDesignable directives in whole project. Commented Aug 24, 2017 at 13:54
Madhuri Mane is totally right regarding this. To add a little more clarity, some important points to note:
This is ONLY applicable if you have implicit dependancies on libraries/frameworks that your target relies on.
If "Find Implicit Dependencies" is disabled :
Result: The library will not get built prior to building the application target. The application target fail to build.
Fix: To ensure that the second scenario does not happen, you must add the necessary targets into the targets list and order them correctly.
Source and further reading on the topic : https://pewpewthespells.com/blog/managing_xcode.html#scheme-action
Now if your entire project is housed within one target and that takes 4 min to compile there isn't much you can do about this except break it up into frameworks to take advantage of the above or figure out where the compilation lags. If you are using something like PaintCode or have large chunks of UIKit code in swift change it to Objective-c it compiles far faster
Go to your target's build settings and set Defines Module to Yes.

Worked for me for a couple builds, too soon to claim this is a definitive workaround, but at least we're trying.
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!
Please go to the build setting of the project and change the "C Language Dialect".
The "C Language Dialect" is set to "GNU99" instead of "Compiler Default" when you update the xcode version. At some point Xcode did not migrate the library project settings correctly and so it was set to GNU99. This will solve the problem
If you have made changes to the Swift file start building the app, go to the last tab and click on the build log, during the "Check dependencies" stage stop the build and run it again. On the second run it should only build the files you modified. If done correctly I have found it works every time. No need to make any project setting changes.
This appears to be a bug in Xcode.
If you see the app is doing a full build then stop the build and try this trick again.
If you have made no changes to the code use CMD + CTRL + R to run without building the app which attaches debugger. Will not build app but can help save unnecessary time.
-
This really works, but sometimes XCode will fail with code 1 and you'll have to make a Clean Build. It's a nightmare Commented Oct 25, 2016 at 17:17
-
There are other scenarios where Xcode will always do full build. I have found if you modify .h file included in bridging header it will rebuild all Swift files. There may be other scenarios which are unrelated to the Xcode bug.– VladCommented Oct 25, 2016 at 17:49
-
There are scenarios where the only change is a function rename or a new property added to an existing class/struct that results in an entire rebuild. Commented Oct 26, 2016 at 18:36
-
Refer to this question/answer, this thread is a duplicate of this: Have solution which works better: stackoverflow.com/questions/39456223/…– VladCommented Oct 26, 2016 at 19:26
Issue from my side fixed by applying the uncheck to "Find Implicit Dependencies" solution.
BUT remember if you're using cocoapods, to apply this settings also to your pod project by selecting it from
Product -> Scheme -> Pods-"yourProjectName"
also apply in:
Product -> Scheme -> "yourProjectName"
It help me, so i hope this hint helps someone else.
Thanks
Try to: 1. Navigate to Project 2. Click Build Settings 3. Check that OptimizationLevel is set to None for debugging. 4. Click Add User-Defined Setting 5. Set SWIFT_WHOLE_MODULE_OPTIMIZATION to YES.
-
nothing to work it still compile when I write a single letter.– ChandniCommented Feb 15, 2018 at 11:44
to fater compilation time of xcode ,can make use of IRAMDISK(Virtual memory disk) . Very useful and effective means to reduce compilation time.
Also can use to speedup frequently used application.
refer following link to download and use: http://iramdisk.findmysoft.com/mac/
-
This won't speed up compilation if you already have a SSD disk.– JanoCommented Jan 13, 2017 at 20:16

