Speed up Xcode Swift build times

后端 未结 5 673
难免孤独
难免孤独 2021-02-04 17:30

As my project has grown over the past year, so have its build times. Over the last few months it\'s gone from 4 minutes to around 7 (time includes GitHub pull, unit tests, etc).

5条回答
  •  悲&欢浪女
    2021-02-04 18:14

    Here's an article about benchmarking/speeding up compilation time - swift-profiling.

    In case it goes dead here is the tldr:

    xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt
    

    You can just run that or add the following flags to your build under the other-swift-flags in build settings:

    -Xfrontend -warn-long-function-bodies=100
    

    This will show you which lines are slowing down your compile time.

提交回复
热议问题