How to optimise Xcode project Build time!!!

Rushabh Singh
Naukri Engineering
Published in
3 min readJun 19, 2021

--

As project grows in size and complexity, Xcode’s build time also increases. In this blog we will see different ways to reduce the build time by modifying some of the Xcode’s Build settings and Code level changes.

We can analyze the Build process with a timing summary which helps us to determine where exactly our build is taking the time and take corrective actions to reduce the build time.

This feature will show the timings of each task performed by the build system and can be found in the XCode

Product → Perform Action → Build with Timing Summary option.

Ways to reduce Xcode build time:

  1. Enable the New Build System

Go to File > Workspace Settings

Change build system from Legacy Build system to New Build system

The new Xcode build system (released in WWDC 17) is written from scratch and purely in Swift. It is more optimised and improves the overall build performance. For Latest Xcode the New Build system is default setting.

Check out this article for more details:

2. Enable Parallelize Build

It will build independent targets at the same time.

Go to Edit scheme > Build

Enable Parallelize build (Not enabled by default)

3. Build Active Architecture Only

Go to Build Settings

Search for Build Active Architecture Only

Set Debug to Yes and Release to No

4. Disable dSYM generation for Debug

Go to Build Settings

Search for Debug Information Format

Set Debug to “DWARF” instead of “DWARF with dSYM File”

Read more about Dwarf and dsym file in this article.

5. Code level optimizations:

a. Mention type annotations so that the compiler doesn’t need to infer types.

b. Use static dispatching wherever possible (Make use of Structs, Final keyword, Private, file private, etc).

c. Remove unwanted header files in source code as it dramatically slows down the compilation and also tends to increase the time required for dependency checking.

d. Identify and optimise Methods and Expressions that takes longer time to compile. This can be done by adding following flags in Build Settings in Other Swift Flags:

For Methods compile time:

-Xfrontend -warn-long-function-bodies=<millisecond>

For Expressions compile time:

-Xfrontend -warn-long-expression-type-checking=<millisecond>

e. Manage Third Party Dependencies

CocoaPods is a simple way to handle dependencies but it builds every time and takes time.

We can use Carthage to manage Third Party Dependencies which build dependencies only once when we update it.

You can find more awesome Code level optimizations in this article.

I will keep on updating this article as I get more clarity on other techniques available.

Thanks for reading.

References :

--

--

Rushabh Singh
Naukri Engineering

Moving fast without breaking things 👨‍💻……. Exploring Mobile Apps development