SoFunction
Updated on 2025-04-09

XCode How to speed up compilation and linking

A solution to speed up the compilation and linking of XCode, a slow compilation of XCode

Recently, I encountered a very headache when developing a large project. Since the project has a lot of code, it takes about 1 minute to compile the link each time, which is a waste of time during debugging. So I studied how to improve the speed of compiled links and share it with you here.

There are three main ways to improve the speed of compilation and linking:

1. Increase the number of threads used during XCode compilation

defaults write PBXNumberOfParallelBuildSubtasks 4 

XCode uses threads with the same number of CPU cores by default to compile, but since there are often more IO operations during the compilation process than CPU computing, appropriately increasing the number of threads can speed up the compilation speed to a certain extent. I use a 4-core CPU, and the compilation speed is slightly improved after changing the number of threads to 8.

2. Change Debug Information Format to DWARF

In the Build Settings corresponding to the Target of the project, find the Debug Information Format item, and change the DWARF with dSYM file during Debug to DWARF.

This item sets whether to add debug information to the executable file and change it to DWARF. If the program crashes, the function stack corresponding to the crash location will not be output. However, since debug information can be viewed in XCode in Debug mode, changing it to DWARF has little impact. After this change, it can greatly improve the compilation speed.

It should be noted that changing Debug Information Format to DWARF will cause the value of member variables of the relevant class type to be unable to view in the Debug window. When you need to view these values, you can change the Debug Information Format back to DWARF with dSYM file, and then recompile it (must).

3. Change Build Active Architecture Only to Yes

In the Build Settings corresponding to the Target of the project, find the Build Active Architecture Only item and change the No during Debug to Yes.

This item sets whether only the current schema version is compiled. If No, the versions of all schemas will be compiled. It should be noted that this option must be No in Release mode, otherwise the published ipa will not be able to run on some devices. After this change, it can significantly improve the compilation speed.

After setting the above three items, the compilation time has been reduced from about 1 minute to about 10 seconds, so the effect is still quite obvious.

Thank you for reading, I hope it can help you. Thank you for your support for this site!