I have an Xcode project which has several targets, among which a shared target which has a dependency dedicated to increasing the build number when archiving.
Whenever I edit my Storyboards, the build number increases, which means the archiving target is run even though it is NOT the active target.
I've noticed that I get warnings on my IBDesignable elements, which according to another answer comes from one of my test targets not currently compiling properly, which confirms my thinking that Storyboard go and compile targets they should not, imho. These are coded in Swift, if it matters.
Henceforth, how do I make sure the storyboard compilation only involves the currently active target?
With any change in code (though file is not in .pch), complete project recompiles every time.
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".
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 !
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..
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
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.
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.
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!
https://developer.apple.com/download/
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.
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.
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/
I have an iPhone app that needs to be physically cleaned to prevent the following build error:
This is what I have in the Navigator:
And this is what I have in the Localization section of Build Settings:
It works, but I'm not sure this ever worked the way it was supposed to; it was written several (like 4) years ago. Now, I am trying to clean it up so I can convert it to a universal app (first I need to make sure it works as designed before making any drastic changes.)
Can someone please point me in the right direction for cleaning this up? (I.e. what files to delete, or ?)
Here is what probably happen in that project:
This xx.lproj file is a legacy. You should be able to find it in Finder but not in a Project Navigator. Like this:
This is only the internal structure of xcode so just remove references from project navigator for all this ``xx.lproj` groups without removing files from project and you'll be fine.
If the app stop building you may need to re-add this files to your target, to do this just select a "parent" storyboard and go to "File Inspector" (first tab on Utilities panel) and select desired target.
I'm using Xcode 4.3.3. My project has 2 targets and they are very similar (one was a duplicate of the other). The only thing is they have different names and there is a small amount of #ifdef going on. One project compiles a few more files and copies a few more bundle resources than the other. Other than that they ought to be the same. It's like having Pro and Lite app versions.
I seem to have a few issues (building for one of the targets is absolutely fine, so all these issues relate to the 'other' target)...
When building the 'other' target it gives me the warning "Multiple build commands for output file...". It is referring to 'icon-72.png'. However, I've not only removed the second reference to that file (still got the warning), but I have also removed that file entirely and removed all references I could find for it, including deleting the icon from the Target Summary, ensuring the file doesn't exist in any project folder in Finder for this project, and also ensuring it's not listed in 'Copy Bundle Resources' in 'Build Phases'. The warning still appears.
When building the 'other' target it doesn't give me the usual warnings. These warnings should exist in both builds at this time. I have checked what is being compiled and the files that should generate these warnings are included in both 'Compile Sources' in both targets' 'Build Phases'.
Building the 'other' target gives me 'Failed'. However, in the Issue Navigator there is no explanation as to why it failed.
Incidentally, the 'other' target was the original one, not the new one.
Also, I have tried cleaning before each build attempt and have also restarted Xcode. I have recently restarted the computer too.
Any help or general pointing in the right direction would be greatly appreciated.
Atb.
EDIT....
I updated the project settings as prompted in the Issue Navigator to use LLDB. Now I don't get any warnings for either target, but the 'other' target still fails to build without reason.
Right. Well, it turns out that this was mostly the answer (check the last comment). I closed the actual Xcode window with my project in (cmd-W), then I went to File > Open and opened the project file from there (as opposed to opening it from the splash window or the recents list).
Now I can see the warnings and tell why the build is failing too. Phew!!
I am working on an app that has 12 localizations of about 16 XIBs.
XCode 4, after a clean and rebuild, says it is compiling 2704 XIBs!
The build log shows that XCode is compiling the same XIB many times for each localization.
Anyone know why this would be?
Note that everything works fine in the app -- this doesn't seem to have any effect as you'd imagine. But it's just wasting my time! :-)
status:
log:
project navigator excerpt:
Yeah, I have encountered this XCode issue too. I don't know how to stop XCode adding xib files multiple times, but there is a workaround to shorten your project build time: you should go to the current target's Build Phases tab and remove all duplicated xibs in Copy Bundle Resources stage, leaving the only copy for each one.
To make my answer more clear:
Inside the Copy Bundle Resources list you should leave only the one item for each individual xib file, in spite of number of languages you have. Something similar to: