加快Xcode Swift的构建时间 [英] Speed up Xcode Swift build times

查看:91
本文介绍了加快Xcode Swift的构建时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着我的项目在过去的一年中不断发展,其构建时间也随之增加。在过去的几个月中,时间从4分钟缩短到了大约7分钟(时间包括GitHub拉取,单元测试等)。

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).

我已经使用 -Xfrontend -debug-time-function-bodies 进行了调查,以找出编译较慢的行,并更改了该代码。

I have investigated with -Xfrontend -debug-time-function-bodies to find lines that are slow to compile, and changed that code.

我认为现在这是项目规模的问题; 182个Swift文件,≈31K行。 23个情节提要,52个XIB。这是一个常规的UIKit应用程序,具有一些Cocoapods依赖项。

I believe it's now a question of project size; 182 Swift files, ≈31K lines. 23 storyboards, 52 XIBs. This is a regular UIKit app with a handful of Cocoapods dependencies.

大部分构建时间都花在了编译Swift源文件阶段。

The bulk of the build time is spent in the "Compiling Swift source files" phase.

我关心的构建机器时间比edit-build-debug周期要少,后者也一直在变慢。

The build machine time I care less about than the edit-build-debug cycle, which has also been slowing.

什么可以改善构建时间吗?

What can be done to improve build times?

推荐答案

这里是有关基准测试/加快编译时间的文章-快速分析

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

万一它死了,这里是tldr:

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

您可以运行它,或在另一个swift下将以下标志添加到构建中-构建设置中的标志:

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.

这篇关于加快Xcode Swift的构建时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆