Xcode 8.3 Indexing & Building Extremely Slow - ios

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

Related

Xcode 14 slow incremental builds

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.

Xcode editor taking too much time in compiling

I'm a newbie in Swift. I just created a new single view project in xcode9.3 and tried building it and its taking forever to compile.
Why is this so?
I have had something similar to this, and I found that restarting Xcode a few times should solve the problem.
If this doesn't work, you might want to download the latest version of Xcode. As of now, I think the latest non-beta version is 9.4.1.
Had the same issue in the past.
The swift compiler have some issues with specific code styles which makes it sometimes compile files even slower.
In the end we quit Swift as a development language and moved to React Native and back to Objective-C on iOS projects as swift became too cumbersome.
Moving forward, you might want to look at some of guides out there.
This two looks promising.
https://medium.com/rocket-fuel/optimizing-build-times-in-swift-4-dc493b1cc5f5
https://github.com/fastred/Optimizing-Swift-Build-Times
Back when I was working on swift, this was guide we were using as a guideline:
Part 1
Part 2

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 6.1 swift autocomplete and code sense broken

I am using Xcode Version 6.1 (6A1052d), it is working well except the only problem is auto complete and code sense is broken for swift projects.
I can fix it by deleting derived data and the folder ~/Library/Caches/com.apple.dt.Xcode, which is described here, or changing the deployment target of the project from 8.1 to 8.0.
However, the first solution only last me for 1 or 2 days, out of no where it doesn't work again, I don't want to delete the folders every so often or change the target iOS versions all the time. Please help me.
I have had the same issue for many days while working in swift, finally I have deleted some old data in the directory ~/Library/Developer/Xcode/DerivedData and started the xcode again and error is disappeared.
Hope it helps!
it's not gone .. I do this procedure 3-4 times a day while coding .. did anyone find a permanent fix? I'm on Xcode 6.3 beta on Yosemite.. on 6.1 I had to do this process more than 5-6 times per day, but they did not fix it entirely :(. I observed that working in one file and not switching back and forth really delays this from happening + if you work with collection views or table views and switch and modify in all files of your MVC architecture, there are greater chances you will need to restart Xcode (which in 6.3 beta fixes this issue automatically). If only there was a way to force a re-indexing on the project ..

Xcode Won't Parse Files to Find Errors

I have a strange issue that I haven't seen or read about anywhere else. My Xcode no longer parses all of my files to find issues/errors. It will display any issues or errors in a file I am currently viewing, and these will persist thereafter, but with 400+ files I can't reasonably visit each one to make it compile. Xcode can build successfully if the code is valid, however I can never know when that is, since I see no errors. Indexing occurs, but no compiling takes place.
Also, when building, the status bar states that Xcode is compiling x out of however many total compile sources but the total number is usually not even close to the actual total number. For example it may say compiling x out of 40 files when there are actually 400 compile sources.
I wasn't doing anything out of the ordinary from my usual tasks when this issue began. New projects will compile, then randomly stop compiling after a period of time.
Things I have tried:
nuking derived data
quitting Xcode/restarting computer
Recloning the project from a known working repository. It will build but won't find errors/issues when they do exist. There should be at least a handful of minor issues but none appear.
Reinstalling Xcode (4.5.2)
tried both GCC 4.2 and LLVM 4.1 compilers
Has anyone experienced this issue before and found a solution? This problem has made my job extremely difficult and any help would be much appreciated.
It does sound like corruption of DerivedData. Try this:
Clean your target: cmd+shift+K or Product->Clean
Quit xcode
Delete the contents of /Users/your_user/Library/Developer/Xcode/DerivedData
Restart xcode
(It's safe to delete this folder's contents. But if you're nervous about that, back it up first).
You should be good to go.

Resources