Other Swift Flags

Add the following flag to Other Swift Flags in the build setting and you can see the detailed compilation time in the building log: – Xfrontend – debug – time – compilation: -xfrontend -debug-time-function-bodies: output function compilation duration -xfrontend -debug-time-expression-type-checking: -xfrontend -warn-long-function-bodies=100: -xfrontend -warn-long-expression-type-checking=100: Warning logs about codes whose compilation time is longer than 100ms usually contain hundreds of thousands of lines, which is extremely readable. There is a tool on GitHub that can easily display these logs. The link is github.com/fastred/Opt… Flag and corresponding tools can be used to locate specific codes with long compilation time, and corresponding modifications can solve the problem of long coding time at the code level.

build setting

  1. Optimization Level: specifies the Optimization Level. Debug is set to None
  2. Debug Information Format: Deletes dSYM files in Debug mode
  3. Build Active Architecture: Debug mode is set to YES to enable only the current Architecture to be compiled faster.

Code specification

  1. Container objects such as dictionaries and arrays require variables to declare types. Untyped container objects add about a second to the compilation time
  2. Do not concatenate objects such as strings and arrays. Concatenating strings with “+” will greatly speed up compilation
  3. Do not use “+-” in logical judgment statements such as if/ “Compute operations



    The above three specifications have a great impact on the compilation time, so it is recommended to strictly abide by them.

    There are many code specifications that can shorten compile times, but most are not practical. For example: complicated +-
    / “and frequent nested type conversions can also lead to long compile times. You can reduce compile times by splitting long computations into shorter ones, but it doesn’t make any practical sense, so you can ignore it.

Reference documentation

The reference documents are more detailed than WHAT I wrote, so I just put them into practice and summarize what’s useful. Koke. Me / 2017/03/24 /… Hackernoon.com/speed-up-sw… Github.com/fastred/Opt… Tool link: github.com/RobertGumme…