Xcode 8 recompiling complete code every time

IosXcode

Ios Problem Overview


With any change in code (though file is not in .pch), complete project recompiles every time.

Ios Solutions


Solution 1 - Ios

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:

enter image description here "Build Setting" tab -> "C Language Dialect" -> Change it to "Compiler Default".

For reference: > 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 !

Solution 2 - Ios

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

Solution 3 - Ios

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

Solution 4 - Ios

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.

Solution 5 - Ios

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).

  1. 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.
  2. 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.)
  3. 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. :))
  4. 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...

Solution 6 - Ios

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.

Solution 7 - Ios

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.

Solution 8 - Ios

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

Solution 9 - Ios

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.

Solution 10 - Ios

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!

https://developer.apple.com/download/

Solution 11 - Ios

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

Solution 12 - Ios

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.

enter image description here

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.

Solution 13 - Ios

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

Solution 14 - Ios

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.

enter image description here

Solution 15 - Ios

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/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMahvishView Question on Stackoverflow
Solution 1 - IosNhat DinhView Answer on Stackoverflow
Solution 2 - IosMadhuri ManeView Answer on Stackoverflow
Solution 3 - IosEmilio ConcepcionView Answer on Stackoverflow
Solution 4 - IosandersView Answer on Stackoverflow
Solution 5 - IosChristopher RogersView Answer on Stackoverflow
Solution 6 - IosJoshView Answer on Stackoverflow
Solution 7 - IosIvan BesarabView Answer on Stackoverflow
Solution 8 - IospflousView Answer on Stackoverflow
Solution 9 - IosldiqualView Answer on Stackoverflow
Solution 10 - IosJohnnyView Answer on Stackoverflow
Solution 11 - IosSamarth KejriwalView Answer on Stackoverflow
Solution 12 - IosVladView Answer on Stackoverflow
Solution 13 - IosMazen SaView Answer on Stackoverflow
Solution 14 - IosNaloiko EugeneView Answer on Stackoverflow
Solution 15 - IosMahvishView Answer on Stackoverflow