MacStadium Blog

All Blog Posts

Speeding Up Xcode Builds

As projects grow, build times can become problematic. However, there are several tweaks you can make to Xcode that can decrease the amount of time it takes for builds to complete without any extra work.

Increase the Thread Count:
By default, Xcode typically uses the same number of threads as the number of cores in the machine’s CPU. However, you can dramatically reduce build times – in some instances by a full 30% - by increasing the thread count beyond the default. This takes advantage of some processors’ ability to multi-thread or simulate additional cores. Keep in mind that you may need to experiment to determine if there are diminishing returns for parallelized builds with your code base, and then adjust the thread count accordingly.

Enable the New Build System:
Apple’s “New Build System” is written completely in Swift and was designed for overall performance and dependency management improvements.  Be aware that while the New Build System is available in Xcode 9+, it must be enabled in Xcode under Project/Workplace Settings since “Standard Build” will be the default option. Alternatively, the New Build System can be enabled via command line (details linked below).  

You can find more details and instructions for enabling the New Build System here:
Xcode New Build System for Speedy Swift Builds

Tweak the iOS simulator:
The Apple iOS test simulator lets you test across different software and hardware combinations (but only from a Mac). By using Physical Size or Pixel Accurate window sizes, you can reduce both the size of your tests and the time it takes for them to complete. Ultimately, these configuration changes use less resources and help prevent tests from slowing down while simulating pixel-perfect iPhone readers that no one will ever see.  

You can find configuration instructions here: Adjusting the Xcode iPhone simulator scale and size  

Use parallelized builds:
Parallelized builds can reduce total Xcode build times by building components of the app that do not depend on each other at the same time.  For projects with many smaller dependencies that can easily be run in parallel, this can offer significant time savings. Gains will obviously depend on how your code is written, but it is worth testing since parallelized builds aren’t enabled by default.  You can enable parallel builds by editing the Xcode Scheme and checking ‘Parallel Builds’ in the build action of the scheme.

You can find more detail on leveraging parallelized builds here:  When should I check “Parallelize Build” for an Xcode scheme?

Turn on build time summary:
Build time summary enables reporting on the build times of each piece of the Xcode build. In other words, build time summary can help you identify the parts of the build that are impacting build times and further optimize the build order for overall gains. While not a fix in and of itself, the insights that build time summary provides can be useful in prioritizing efforts when trying to optimize your build times.

Bigger build machines:
This one isn’t technically an Xcode tweak, but bigger build machines do have an outsized impact when attempting to speed up builds. More computing power simply translates into faster completion of processes and builds. Our testing shows that moving from a dual-core Mac mini to a 12-core Mac Pro can give a 3x speedup without any additional effort.  When you’re ready to upgrade or scale your Mac infrastructure, feel free to contact us at MacStadium.

Additional Resources:
Of course, these are only a few of the suggestions you can use to speed your Xcode build times. The following resources can provide additional information and suggestions on improving your Xcode build times.

Optimizing Compilation Time for Swift Code

Shaving off 50% waiting time from the iOS Edit-Build-Test cycle

8 tips to speed up your Swift build and compile times in Xcode

How to Build Better Apps with Xcode 9 and iOS 11