Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease build times / speed up compile time in Xcode?

What strategies can be used in general to decrease build times for any Xcode project? I'm mostly interested in Xcode specific strategies.

I'm doing iPhone development using Xcode, and my project is slowly getting bigger and bigger. I find the compile / link phases are starting to take more time than I'd like.

Currently, I'm:

  • Using Static Libraries to make it so most of my code doesn't need to be compiled everytime I clean and build my main project

  • Have removed most resources from my application, and test with a hard coded file system path in the iPhone simulator whenever possible so my resources don't have to constantly be packaged as I make changes to them.

I've noticed that the "Checking Dependencies" phase seems to take longer than I'd like. Any tips to decrease that as well would be appreciated!

like image 944
Brad Parks Avatar asked Sep 25 '09 19:09

Brad Parks


People also ask

Why does Xcode build take so long?

Xcode has inbuilt features that allow you to identify functions and expressions that are causing longer compile times. You can specify a compile time limit and identify areas in your codebase that exceed this limit. Open up your project's build settings and add the following flags to your Other Swift Flags .

How does Xcode determine build time?

If you use Xcode, Product->Perform Action->Build With Timing Summary . And see building time summary in the Xcode building log.


2 Answers

Often, the largest thing you can do is to control your inclusion of header files.

Including "extra" header files in source code dramatically slows down the compilation. This also tends to increase the time required for dependency checking.

Also, using forward declaration instead of having headers include other headers can dramatically reduce the number of dependencies, and help all of your timings.

like image 158
Reed Copsey Avatar answered Oct 01 '22 05:10

Reed Copsey


I wrote an extensive blog post about how I improved the iOS development cycle at Spotify:

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

It boiled down to:

1) Stop generating dSYM bundles.

2) Avoid compiling with -O4 if using Clang.

like image 23
fons Avatar answered Oct 01 '22 05:10

fons