2016-06-02 Good error messages in Xcode Run Scripts phase

Xcode has an option to run a script when building. This is necessary for example when using Carthage. Reading the instructions, Carthage says: "Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell: /usr/local/bin/carthage copy-frameworks"

However, to make things easy for your (new) colleagues, I urge you to create an extremely clear error message. You can do this as follows. First, when adding a Run Script phase, change the shell to /bin/bash. Then add an error message by checking for prerequisites, and printing to stderr combined with an "exit 1". For Carthage you could do the following:

    CARTHAGE="/usr/local/bin/carthage"
    if [[ -e "$CARTHAGE" ]]; then
        /usr/local/bin/carthage copy-frameworks
    else
        echo "--------------------------------------------------------"  1>&2
        echo 1>&2
        echo "Please install carthage, see also:"  1>&2
        echo "https://github.com/Carthage/Carthage#installing-carthage"  1>&2
        echo 1>&2
        echo "--------------------------------------------------------"  1>&2
        exit 1
    fi

This results in the following very obvious message when Carthage is not installed:

carthage build error 2016-06-06.png

I don't think anybody would object to such a nice pointer in the right direction.