Search code examples
xcodebuild-process

How to abort build if run script phase gives an error


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.


Solution

  • 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".