How to abort build if run script phase gives an error

Viewed 8683

I would like to use a run scripts target to tag my revision in mercurial and upload it to a server. I created a new run scripts target that depends on the other target building my app, then I added two run script phases directly one after another.

Now my question: how can I prevent executing run script phase #2 if run script phase #1 gives an error (return code of script is unequal 0)?

The second script would upload the files to a server, so I only want to execute this phase if everything went right until then.

3 Answers

exit 1 aborts the build.
echo "error: will flag it up as an error within Xcode.

echo "error: Everything has failed!"
exit 1

Custom Error example

Related