Search code examples
iosobjective-cxcodebuildcompile-time

Get Xcode Build Time


I want to extract the overall build time of an Xcode project displayed in the small box above Xcode if you enabled defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES.

enter image description here

I don't find any information in the .xcactivitylog files.

I also tried the approach to save the time via a build phase script at the very top, but including some pods this would need to be also in every pod as build phase script..

Does Xcode save this information somewhere?


Solution

  • This case could be solved using scripts that runs before and after the build. You can set them up in Xcode -> Preferences -> Behaviors Xcode -> Preferences -> Behaviors

    On start you can assign:

    #!/bin/sh
    echo `date +%s` > test.txt
    

    and on the end

    #!/bin/sh
    startTime=$(head -n 1 test.txt)
    currentTime=`date +%s` 
    diff="$(($currentTime - $startTime))"
    # do whatever you need with compilation time