如何在 Xcode 中启用构建计时?

发布于 2024-07-25 02:36:19 字数 71 浏览 2 评论 0原文

我想知道我的项目的构建需要多长时间,例如通过在构建窗格中显示它。 Xcode 中是否有此选项?

谢谢。

I'd like to know how long my project's builds take, for example by displaying it in the build pane.
Is this option available somewhere in Xcode?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陪你搞怪i 2024-08-01 02:36:19

在终端中输入以下内容:

defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES

构建后,持续时间将显示在活动查看器中,旁边会显示“成功”消息。

如果您正在运行该应用程序,则在您可以看到持续时间之前,状态将替换为正在运行的状态。

这取代了旧版本 Xcode 中使用的条目:

默认写入 com.apple.Xcode ShowBuildOperationDuration YES

在输入此命令之前,可能需要关闭 Xcode。 持续时间应显示在项目窗口的左下角。

来自 Xcode 开发人员的评论:“与所有未记录的用户默认值一样,这是不受支持的,假设(但不保证)准确,并且不保证在未来版本中有效。”

Type this in the terminal:

defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES

Duration appears in the activity viewer after a build, alongside the "Succeeded" message.

If you are running the app, the status will be replaced by the running status before you can see the duration.

This replaces the entry that was used in older versions of Xcode:

defaults write com.apple.Xcode ShowBuildOperationDuration YES

Xcode may need to be closed before you enter this command. Durations should appear at the bottom left of the project window.

Comment from an Xcode developer: "As with all undocumented user defaults, this is unsupported, assumed (but not guaranteed) accurate, and not assured to be effective in future versions."

怪我鬧 2024-08-01 02:36:19

在 Xcode 10 中,您现在可以使用其时序摘要功能查看构建时间的详细细分。

产品 -> 执行操作 -> 使用计时摘要构建

这将显示您的每个目标构建时间和总体项目构建时间。 您可以使用这些数据进行大量分析,构建时间将取决于您的硬件。 查看在 Xcode 中更快地构建如果您想了解更多信息,请参加 WWDC 2018。

但是,Xcode 默认情况下会跟踪您的所有构建,您可以通过转到报告导航器来检查它们的时间和日志。

在报表导航器中构建日志

In Xcode 10, you are now able to see a great breakdown of the build times using their Timing Summary feature.

Product->Perform Action->Build With Timing Summary

This will show each of your target build times and the overall project build time. You can do a lot of analysis using this data and build times will depend on your hardware. Check out Building Faster in Xcode from WWDC 2018 if you care to learn more.

However, Xcode keeps track of all your builds by default and you can examine their times and logs by going to their Report Navigator.

Build Logs within Report Navigator

要走干脆点 2024-08-01 02:36:19

不,但您可以使用命令行。 cd 到您的项目目录并输入

time xcodebuild

no, but you could use the command line. cd to your project directory and type

time xcodebuild
独守阴晴ぅ圆缺 2024-08-01 02:36:19

在 Xcode 10 之后

  • ,如果您从命令行构建,请使用 -showBuildTimingSummary 查看构建时间摘要。
xcodebuild -showBuildTimingSummary
Build Timing Summary
CompileSwiftSources (1 task) | 5.434 seconds
PhaseScriptExecution (1 task) | 5.046 seconds
CompileAssetCatalog (1 task) | 2.788 seconds
CompileStoryboard (1 task) | 1.880 seconds CompileMetalFile (5 tasks) | 1.735 seconds
CopySwiftLibs (1 task) | 0.740 seconds
Ld (2 tasks) | 0.306 seconds
CodeSign (3 tasks) | 0.177 seconds
CompileC (1 task) | 0.170 seconds
MetalLink (2 tasks) | 0.046 seconds
Ditto (4 tasks) | 0.032 seconds
LinkStoryboards (1 task) | 0.023 seconds
  • 如果您使用 Xcode,Product->Perform Action->Build With Timing Summary。 并在 Xcode 构建日志中查看构建时间摘要。

After Xcode 10

  • if you build from command-line, use -showBuildTimingSummary to see the build time summary.
xcodebuild -showBuildTimingSummary
Build Timing Summary
CompileSwiftSources (1 task) | 5.434 seconds
PhaseScriptExecution (1 task) | 5.046 seconds
CompileAssetCatalog (1 task) | 2.788 seconds
CompileStoryboard (1 task) | 1.880 seconds CompileMetalFile (5 tasks) | 1.735 seconds
CopySwiftLibs (1 task) | 0.740 seconds
Ld (2 tasks) | 0.306 seconds
CodeSign (3 tasks) | 0.177 seconds
CompileC (1 task) | 0.170 seconds
MetalLink (2 tasks) | 0.046 seconds
Ditto (4 tasks) | 0.032 seconds
LinkStoryboards (1 task) | 0.023 seconds
  • If you use Xcode, Product->Perform Action->Build With Timing Summary. And see building time summary in the Xcode building log.
巡山小妖精 2024-08-01 02:36:19

我用构建阶段中的运行脚本解决了这个问题,

我在构建的起点添加了一个运行脚本:

echo $(date +%s) > > ../build_start_time

和最后一个:

START=$(cat ../build_start_time)
END=$(date +%s)
echo $(echo "$END - $START" | bc)

现在我可以在构建日志中看到时间 -> 所有消息

I solved it with Run Scripts in Build Phases

I have added one Run Script at start point of the build:

echo $(date +%s) > ../build_start_time

and one at the end:

START=$(cat ../build_start_time)
END=$(date +%s)
echo $(echo "$END - $START" | bc)

Now i can see the time in Build Log -> All Messages

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文