Search code examples
xcodexcodebuild

Detect if Xcode is currently building


I want to track the time I am waiting for Xcode to be ready in a typical workday. From pressing "Run" to seeing the app on my sim/iphone screen. Is there a way to detect if Xcode is currently building/linking/copying something? At the moment I just do a glorified version of

ps ax | grep "/clang"

Is there a better way to do this? I looked into the scripting bridge header of Xcode but I could not find anything.

Thanks


Solution

  • You could add two "Run Script" build phases to your Xcode project which runs a tiny script. One at the beginning and at the end of building.

    The script at the beginning could literally be something like

    #!/bin/sh
    
    date=`date`
    # this echo puts the line into your Build Log
    echo "time started building is $date"
    # and doing a "cat" into some file will save it
    cat "time started building is $date" > /path/to/your/buildlog.txt
    

    and the same thing at the end.

    You can also do "Pre-Action" and "Post-Action" methods in your Build scheme. They might look like this:

    Only here, you'd do the appropriate script thing.