Xcode 14 slow incremental builds - ios

After updating to Xcode 14.0 (happens still for 14.0.1, and 14.1) I felt massive slowdown in incremental build times even if changing just a single property. For my project it's 3x, but read about 10x or more.

To fix that, you simply need to add user defined build setting SWIFT_USE_INTEGRATED_DRIVER and set it's value to NO you can do so by going to project navigator -> select your target -> Build Settings -> Now you need to click on the plus in the section below and tap "Add User-Defined Setting"
Xcode should scroll to the field and focus on it automatically, but if not scroll to the bottom or search for your field in the filter on the right and set your value to "NO"
This topic is covered more broadly on swift forum and this is from where I got this fix
I believe this is a temporary solution, due to some swift driver issues, if I found it to be no longer needed. I'll update the answer. From my own observations, I can't see any parallel compilations tasks being run with the driver on. Only one big emit module for main app target.

Xcode 14.1 has the same bug. Due to the previous answer I've updated from 14.0.1 to 14.1 today and the build times increase from build to build in exponential manner, below tested for the first 10 subsequent compilations without (!) any changes to the code base:
Update: The problem occurs only after the first debug run with or without change the code base.
Interestingly the time cannot understand by sum up the part times shown in the build statistic:
Deleting derived data folder doesn't resolve the problem.
The only working workaround is to close/open the whole project, making some changes, compile, close/open etc.
It's a mess.

The last Xcode update (1 November - Version 14.1.0) fixed the issue for me.
When i updated to 14.0.1 i felt massive increase in the build time, it was extremely slow. Now i can't say is it like before, but for sure it's better.
Here is the summary:
Xcode 14.0.0 - Builds fast
Xcode 14.0.1 - Builds very slow
Xcode 14.1.0 - Builds faster than 14.0.1
You can also try to download and install an older version from here, if the update doesn't work for you.

Related

Xcode 9 is taking too much time to load the Application

I just installed the Xcode 9 for iOS 11 for my older project to update.
But it's taking too much time to load the app in Simulator as well as in iOS devices.
Are there any settings that I need to change in Xcode?
Also, I found one major issue is hitting the Mac machine.
I found another problem with Xcode recommended settings for Pods.
If you accept recommended settings, Xcode changes optimization level for Pods project to "Fast, Whole Module Optimization". It changes both of Debug and Release. You can change manually only for Release. That fixed my unnecessary building problem.
If you accepted recommended settings before, close Xcode and update and re-install pods. Than change optimization level for Pods project manually.
My First Answer
Commit changes and try again. It worked for me.
If you don't use git or another source control, you can find commit in Xcode's "Source Control" menu.
I'm not sure but It's good to clean compiled things too.
(on XCode menu > Product > Clean)
Sometimes delayed launching is because of large chunks of data being bundled with the app.
For eg: If you are uplaoding a json with huge data, the app will take time to process , bundle and install it which subsequently will lead to a delayed launch of the app.
So you need to verify whether something like that has been added to your project.

Xcode 8.3 Indexing & Building Extremely Slow

I am posting this after reading many similar posts on here regarding this issue and none of the solutions that worked for other people not working...
Xcode Version 8.3.3 (8E3004b)
Swift 3.1
Things I tried
Deleting Derived Data folder
Deleting Workspace File
Cleaning Build Folder
Cleaning Build
Reinstalled Xcode (after complete removal)
I also looked for Swift Issues:
Removed all concatenating strings
Cleaned up Swift arrays and dictionaries
Added Whole module optimizations
This all started happening after last Xcode update of 8.3.3. My project was compiling within seconds and now I have to wait at least 15 mins for it to index, then 5 minutes to compile after everything I change even something small in code.
When Building, it get stuck in "Compiling Swift source files". Is there way for me to look in to where it is actually getting stuck?
BIG UPDATE
I tried pretty much everything. Read every article, post, ect. NOTHING worked. My project was created right after 10.0.
Solution
Creating a new project and copying each file worked! It used to take 8-9 minuted to build. Now less than 2 seconds!
Apple knows about this problem, and says that Xcode 9 beta will perform much better. Note that if you don't want to update to Swift 4, you can continue compiling in Swift 3 mode using Xcode 9. The big limitation is that you won't be able to submit your project to the App Store until Xcode 9 goes final.
Also, Xcode 9 contains a new build system. You don't get it by default: you have to turn it on for this project. Choose File > Project Settings and switch the pop-up menu to New Build System (Preview). This is experimental, but it will be the default build system eventually, so it would be interesting to know whether this makes an appreciable difference.
If you don't want to update to Xcode 9 beta, you will just have to do a binary search: comment out all your code and start adding it back, piece by piece, until you find that piece that's causing the trouble.
The best way to work this out is to find what out what the build is doing while compiling your code. This is a really useful tool to use: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode
When you run this tool it will show you what methods are taking the longest to compile, and then you fix those. Once you have done that, you can also try the answer I gave here to decrease the build times: Extremely long compilation times with Swift in Xcode

Extremely long compilation times with Swift in Xcode

I have three iOS projects:
First one - 35k Swift LOC, Swift 2.1 (or 2.0?), compiled using Xcode 7.2.3
Second one - 15k Swift LOC, Swift 2.3, compiled using Xcode 8.2.1
Third one - 15k Swift LOC, Swift 3.0, compiled using Xcode 8.2.1
The compile times for all of these are abysmal (10+ minutes for a clean build), and the development on each one of these is slowing to a crawl.
I have already tried:
Using Whole Module Optimization
Changing C Dialect to compiler default
Analyzing build times for the project and optimizing bottlenecks (a few methods that took 6-10s to compile with array concatenation, nil coalescing operators and such), which shaved like 15 seconds - completely unnoticeable difference
HEADERMAP_USES_VFS = YES
A few other I don't remember now
I'm working on a Mac mini Late 2014 with an SSD, 8GB RAM & 2.6ghz i5, if that matters.
Anyone knows what might cause that, what to do with that or even any workarounds for now? From what I've read on SO and other places, it seems like an unresolved compiler issue.
EDIT: Yes, I'm using Cocoapods for dependencies. I'll try moving to Carthage and see what happens.
Try set the following in Build Settings as a workaround. I am assuming you have just one Target.
Set the Build Active Architecture Only to Yes.
Set Optimization Level to None [-Onone]
Add User-Defined setting called "SWIFT_WHOLE_MODULE_OPTIMIZATION" with the value "YES"
Empty your derived data and build.
You can also then use this tool to analyze any slow compiling Swift files: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode
I was experiencing build times that were taking 6-7 minutes. I moved away from Cocoapods and started using Carthage which helped for clean builds. Even then builds were still taking 3 minutes. The biggest improvement came with the steps I mentioned above.
Update
Instead of adding the User-Defined setting, on your Debug build set the Optimization Level to 'Fast, Whole Module Optimization'. Then in Other Swift Flags for your debug build add '-Onone'.
It's an open issue on swift's site: https://bugs.swift.org/browse/SR-6037
Hopefully they'll fix it soon.

Xcode 6.3 always does full rebuild of Swift project

One of the long anticipated features of Swift 1.2/Xcode 6.3 is incremental builds. They worked fine for me until recently, but now almost every time I change even a single line of code it does full rebuild.
I tried restarting Xcode, computer, cleaning derived data, but to no avail. Googling doesn't seem to reveal anything.
Does anyone else have this problem? How do I fix it?
I think that this is what you searching for
I am not this is a source of the problem. According to https://developer.apple.com
Swift Performance
A new compilation mode has been introduced for Swift called Whole Module Optimization. This option optimizes all of the files in a target together and enables better performance (at the cost of increased compile time). The new flag can be enabled in Xcode using the “Whole Module Optimization” build setting or by using the swiftc command line tool with the flag -whole-module-optimization. (18603795)

Xcode rebuilds project when nothing has changed

In the last few months we've noticed that Xcode seems to be rebuilding our project every time we 'Run', even if no files have changed. How do I determine what is causing this to happen so that I can prevent it?
We did start using Swift in the last few months as well...not sure if it's related.
Also, one reason that the problem is so noticeable is because of some extra build phases that we have which execute shell scripts that take time.
I am not sure if it's intention by Apple, or an Xcode bug. However, you can select ⌘⇧R (command+shift+R) to rerun without rebuilding.

Resources