5 Tips to Speed Up Xcode Builds — iOS/macOS

Imad Ali Mohammad
3 min readJul 13, 2022

--

Here are a few tips which would improve your Xcode build time.

TIP 1 — Deleting derived data

Xcode can often do some strange things that cause build problems etc. One of the go-to methods to try and fix these issues is to delete derived data.

There are two ways to find the derived data folder:

  1. One using short-cut method using command-line:

rm -rf ~/Library/Developer/Xcode/DerivedData

2. And other using: In Xcode, open preferences go to Locations tab, locate the project's derived data folder, and delete files related to the project.

Xcode Preferences — Locations

TIP 2 — Clearing SwiftUI Cache

SwiftUI previews are super helpful during development but they take a lot of disk space. To free up your disk and delete the cached SwiftUI previews you can use the following terminal command.

Command to clear SwiftUI preview caches

TIP 3 — Improve Compilation time

The ‘Compilation Mode’ tells the compiler whether to build all files in the project or only the modified files. ‘Incremental’ says to compile only the files that are altered and ‘Whole module’ denotes building all files in the project irrespective of the changes made.

  1. Goto ‘Compilation Mode’ in build settings. By default, Xcode 10 (&above) should have set it to ‘Incremental’ for Debug and ‘Whole Module’ for Release.
  2. If the build settings in your project look like the below, then we’re good. Else, you need to make sure that this setting is in place.
Xcode Project — Settings — Swift Compiler

TIP 4 — dSYM impact

dSYM files are helpful during de-symbolication process of crash report files. The compiler takes time to produce the dSYM file. It makes sense to have it enabled only when the Xcode debugger is not attached. So, it is better to have it disabled when we are running on the simulator.

Xcode Project — Settings — Build Options

TIP 5 — Show Build time

This generally doesn’t help to improve your build time but it shows the time taken to build your project, which helps to play/alter with settings.

By default, Xcode doesn’t display the build time, so we’ll have to enable it. Run the following in the command line to enable it.

defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES

Xcode — Build time is 6.335s

Hope it helps !!! If it helped you then you can clap 👏 for me ☺️

Start using it in your projects when it is required 🚀

--

--

Imad Ali Mohammad
Imad Ali Mohammad

Written by Imad Ali Mohammad

Senior iOS Engineer, Passionate about coding and building amazing apps.