views:

28

answers:

1

Hello all,

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. Not 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.

Thanks Thomas

+2  A: 

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

w.m
Interesting! Is that also possible to set for a specific target?
GorillaPatch
Do you mean via xcodebuild? If you are building multiple targets with one call, just split them up to use different xcodebuild commands, each with a different -target ... and -PBXBuildsContinueAfterErrors=0/1
w.m
I though more about the builds initiated from Xcode.
GorillaPatch
I can't think of a good solution for that right now. Since it is an application wide setting, it's hard to change that for specific target (it is ignored if you set add it in the target settings). You could meddle with the defaults at com.apple.Xcode, but that won't have an impact until the next restart of the Application.
w.m
What would you need it for? If you need it only for your scripts, then just let the script exit with 0 if you want the build to continue even if an error occurs. You could tell the script how to behave by an env variable, which you could set differently for each target.
w.m
The idea is to have a target that checks if there are uncommited changes in the SCM using a script, then builds the product, makes sure that no errors occured and then uses a second script to tag the revision with a version number and also sets it in the Info.plist file to get it ready for distribution.
GorillaPatch