How to reduce Xcode build time?
As our codebase grows, build times can increase and you spend a lot of time in building the project. In this article, I’ll explain to you some approaches to reduce the Xcode build time. I hope that these can be helpful to you.
Get Started
1. Display build time in Xcode
To display build time, you should enable the compile timer. Open the command line and hit the following command:
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES
To see the time after hitting the command, clean project(cmd + option + k) or delete project derived data.
2. Find code that compiles slowly
Open the project’s build settings and add the following flags to your Other Swift Flags. As in the below screenshot:
Functions who take long compile time:
-Xfrontend -warn-long-function-bodies=<millisecond>
Expressions who take long compile time:
-Xfrontend -warn-long-expression-type-checking=<millisecond>
When you build the project, you can see the warning times in the Xcode build log.