127

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.

Guillaume
  • 4,901
  • 5
  • 24
  • 19

5 Answers5

256

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

mohamede1945
  • 7,092
  • 6
  • 47
  • 61
Guillaume
  • 4,901
  • 5
  • 24
  • 19
31

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

Andrew
  • 311
  • 3
  • 6
  • there is no way I can save the build log from XCode with timings. I can only see time in XCode output – msk Feb 16 '19 at 13:56
11

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

time xcodebuild
Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200
8

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.
RY_ Zheng
  • 3,041
  • 29
  • 36
4

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

adsurbum
  • 3,107
  • 3
  • 22
  • 27
  • 1
    In Xcode 6.4, it won't let you drag a run script build phase before any of the "stock" build phases. If you create a bunch of additional build phases, it will let you re-order those among themselves, but it appears all of the "stock" build phases must come first. Have you found a way around this? – Jason Pepas Aug 03 '15 at 16:07