How do I optimize compile times?

There are some good answers here, but just wanted to say—usually I add this flags:

package.targets
  .filter { $0.type != .binary }
  .forEach {
    $0.swiftSettings = [
      .unsafeFlags([
        "-Xfrontend",
        "-warn-long-function-bodies=100",
        "-Xfrontend",
        "-warn-long-expression-type-checking=100"
      ])
    ]
  }

which highlights me functions and expressions that take more than 100ms and show a warning. Then I just split those functions/expressions into smaller pieces and it improves compile time greatly.


think there was another discussion not so long ago, not sure if it's helpful or not (from comments see same -warn-long-function-bodies there...

7 Likes