Compile Time Incredibly Slow

后端 未结 8 1137
执笔经年
执笔经年 2020-12-22 23:57

My project consists of ~350 Swift files and ~40 cocoa pod dependencies.

As soon as the entire project was migrated to Swift 3, build times have been <

相关标签:
8条回答
  • 2020-12-23 00:25

    I migrated a Swift 2x project of 17 files to Swift 3 and had 28 warnings and 55 errors across all files. Compile time was 4-5 minutes.

    Disabling

    Find Implicit Dependancies 
    

    in scheme and

    SWIFT_WHOLE_MODULE_OPTIMIZATION = YES 
    

    made only minor improvements.

    As I eventually cleared the warnings and errors in each file, the compile time reduced and is now in the seconds. The IDE is back behaving as it should - detecting errors in near real time and compiling quickly.

    Firstly, it looks like the compiler is recompiling (or at least cross checking) every file with any error or warning - even if you haven't edited that file since the last compile.

    Secondly, if there are too many dependant errors/warnings across files, the compiler bottlenecks and slows right down.

    0 讨论(0)
  • 2020-12-23 00:34

    Concatenating several Strings also can cause increasing compiling times, for example in my case, my compilation times where very high because of this line:

    let fecha = post.dia + " " + post.num_dia + " " + post.mes + " - " + post.hora
    

    When i changed the code to this, it satart compiling in seconds:

    var fecha = post.dia!
    fecha = fecha + " "
    fecha = fecha + post.num_dia!
    fecha = fecha + " "
    fecha = fecha + post.mes!
    fecha = fecha + " - "
    fecha = fecha + post.hora!
    
    0 讨论(0)
提交回复
热议问题