How to abort build if run script phase gives an error

A solution would be to generally stop building when errors occur:

XCode -> Preferences -> Building -> Build options "Continue building after errors".

If you uncheck that, the build will stop if your script returns something unequal 0 and the second script will not be executed. If you use xcodebuild, the name for the setting is "PBXBuildsContinueAfterErrors".


Your first script can abort the build with "exit 1", like this:

if [ error ] then
    echo "There are some errors, etc..."
    exit 1
fi