All Blog Posts

Speeding Up Xcode Builds

9 Tweaks to Speed 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.

UPDATE: This article has been expanded to add two factors to think about when speeding up VMs. In addition, this article references Xcode 9. With reports that Xcode 11 builds are up to 50% slower, Xcode build speed has become an even hotter topic.

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. These configuration changes use less resources and help prevent tests from slowing down simulating pixels 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.

UPDATE - Increase your clock speed:

With the recent Xcode 11 release, more and more builds are showing signs of single-threaded-like behavior. That is, some elements are not being run in parallel like before. In this event, hardware with more cores is not necessarily better. MacStadium is currently finding customers can complete builds faster by picking a 6-core 2013 Mac Pro, which has a 3.5 GHz clock speed over the 12-core 2013 Mac Pro at 2.7 GHz. Individual builds vary, but this a factor to check.

UPDATE - Enable caching:

Xcode now supports caching automatically as long as users do not run the Product > Clean feature before builds. This is a great improvement for local developers who are the primary audience for Apple’s continued development. For teams, the caching features of Bazel make it a very attractive choice. The implementation of Bazel is not always easy, but implementing Bazel for iOS and macOS builds was the specific focus of the 2019 BazelCon. All the talks are now on YouTube.


New from MacStadium: Virtualize macOS on Orka

If you’re running dozens or hundreds of builds a day as part of a CI pipeline, you can improve performance by leveraging a virtualized Mac fleet. Orka, the first and only solution built for orchestrating genuine Apple hardware allows you to orchestrate many build machines using Kubernetes technology.

You can try an Orka sandbox and see for yourself how easy it is to manage a Jenkins pipeline, spin-up VMs and achieve near bare metal speeds on a hypervisor built specifically for macOS and iOS app development. Have questions? Talk to a sales engineer about how Orka can transform your Xcode build process.


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


You May Also Like

Was this article helpful?

Vote Submitted
Oops! Something went wrong while submitting the form.
Vote Submitted
Oops! Something went wrong while submitting the form.
Return to Blog Home