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. – Josh Sep 20 '16 at 21:01
-
1I too get this issue. – AJ9 Sep 22 '16 at 10:57
-
3Are you modifying xib/storyboards with some IBDesignable stuff? – Larme Sep 26 '16 at 13:25
-
1Related apple forum thread: https://forums.developer.apple.com/thread/62737. No workaround still. – ldiqual Sep 29 '16 at 19:28
-
Use CMD + CTRL + R to run without building the app which attaches debugger. Will not build app but can help save unnecessary time. – Vlad Sep 30 '16 at 16:24
-
1Make sure to open a bug report, as suggested in the Apple forum. – Léo Natan Sep 30 '16 at 16:30
-
How is your project set up? Is it a workspace? Does it contain either sub-projects or included projects (if workspace)? Additionally how are they setup in the Scheme? – Mobile Ben Sep 30 '16 at 18:42
-
Can you give more info? Objc ? Swift + objc ? Swift 3 ? What files are you changing for example (just give a simple example). Do you get the same compilation process as when you clean you project and build or do you have less files to build when you just change a file and run ? – Mikael Oct 05 '16 at 03:13
-
1Please take a look at this question :- http://stackoverflow.com/questions/36438919/xcode-7-3-library-project-compiles-every-time – Bharat Nakum Oct 05 '16 at 12:27
-
Possible duplicate of [Xcode 8 does full project rebuild](http://stackoverflow.com/questions/39456223/xcode-8-does-full-project-rebuild) – Vlad Oct 12 '16 at 22:24
-
What worked for me was to recreate the build target. It works, I don't know why. – Adi Oct 21 '17 at 21:21
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 !

- 3,378
- 4
- 35
- 51
-
1So far so good!!! Give me one hour and the bounty's yours if it keeps up. – Adam Waite Oct 05 '16 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. – bluebamboo Oct 10 '16 at 02:58
-
-
-
@RaviSisodia Did you tried to "Build Setting" tab -> "C Language Dialect" -> Change it to "Compiler Default". ? and change your Debug information format to DWARF ? – Nhat Dinh Dec 08 '16 at 13:35
-
@NhatDinh, Yes. I didn't help. Start recompiling after working fine for some builds, as usual. – Ravi Sisodia Dec 13 '16 at 06:53
-
1Xcode 8.2 (beta 2) works for 10 builds then rebuilds everything from scratch, but still better than previous one. – Markus Dec 15 '16 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. – Kasper Munck Feb 10 '17 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..

- 5,205
- 2
- 36
- 62

- 253
- 1
- 3
-
@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? – Mobile Ben Sep 30 '16 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. – Josh Sep 30 '16 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. – Josh Sep 30 '16 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. – Womble May 20 '18 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

- 71
- 1
- 4
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.

- 4,168
- 2
- 23
- 31
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...

- 6,759
- 1
- 22
- 13
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.

- 1,688
- 4
- 22
- 35
-
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 – Antonio Junior Oct 25 '16 at 17:14
-
-
2
-
1if you don't see it then read this http://meandmark.com/blog/2011/03/xcode-4-accessing-build-settings/ – Laser Hawk Nov 29 '16 at 07: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.

- 990
- 7
- 12
-
We use quite a number of `@IBDesignable` directives... is there anything in particular that we should look for? – Stan Aug 21 '17 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. – Ivan Besarab Aug 24 '17 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

- 573
- 6
- 17
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.

- 15,015
- 6
- 52
- 90
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!

- 2,589
- 2
- 27
- 34
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

- 1,168
- 2
- 15
- 30
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.

- 5,727
- 3
- 38
- 59
-
This really works, but sometimes XCode will fail with code 1 and you'll have to make a Clean Build. It's a nightmare – Antonio Junior Oct 25 '16 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. – Vlad Oct 25 '16 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. – Antonio Junior Oct 26 '16 at 18:36
-
Refer to this question/answer, this thread is a duplicate of this: Have solution which works better: http://stackoverflow.com/questions/39456223/xcode-8-does-full-project-rebuild/39477414#39477414 – Vlad Oct 26 '16 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

- 19
- 1
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.

- 2,453
- 1
- 28
- 18
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/

- 1,383
- 2
- 9
- 4