How to prevent script phase from running when there was a compile or link error

  • In Xcode 3.2.6, I've got a script phase that runs after everything else is done, but it always runs even if there is a compile or link error prior to that.  I don't want to have the compiler stop on build errors, but I also don't want to execute [at least a portion of] my script, because it will always fail if the link hasn't been performed or hasn't succeeded.  I don't see any way to control the execution of the script in this manner, though.  Is there a variable that gets set when linking has succeeded (or failed) that I can use to tell my script to skip over all or part of it?

    Thanks,
    Howard
  • On May 29, 2013, at 10:50 AM, Howard Moon <howard...> wrote:
    > In Xcode 3.2.6, I've got a script phase that runs after everything else is done, but it always runs even if there is a compile or link error prior to that.  I don't want to have the compiler stop on build errors, but I also don't want to execute [at least a portion of] my script, because it will always fail if the link hasn't been performed or hasn't succeeded.  I don't see any way to control the execution of the script in this manner, though.  Is there a variable that gets set when linking has succeeded (or failed) that I can use to tell my script to skip over all or part of it?

    If you’ve turned on the “Continue Building After Errors” preference (which it sounds like you have), then Xcode doesn’t provide any support for what you’re trying to do.

    Your best bet would be to add a clause to your script to check whether the linked binary exists at the destination path (if it the link failed or the link was killed by Xcode [e.g. because the build was cancelled] then Xcode will have removed any partially-linked binary), and skip the meat of your script if it’s missing.  You may wish to have the script emit an error message or return a nonzero exit code in that case.

    --
    Michael Rawdon
    <rawdon...>
    Xcode Developer
    Apple Inc., Cupertino CA
  • On May 29, 2013, at 10:59 AM, Michael Rawdon wrote:

    > On May 29, 2013, at 10:50 AM, Howard Moon <howard...> wrote:
    >> In Xcode 3.2.6, I've got a script phase that runs after everything else is done, but it always runs even if there is a compile or link error prior to that.  I don't want to have the compiler stop on build errors, but I also don't want to execute [at least a portion of] my script, because it will always fail if the link hasn't been performed or hasn't succeeded.  I don't see any way to control the execution of the script in this manner, though.  Is there a variable that gets set when linking has succeeded (or failed) that I can use to tell my script to skip over all or part of it?
    >
    >
    > If you’ve turned on the “Continue Building After Errors” preference (which it sounds like you have), then Xcode doesn’t provide any support for what you’re trying to do.
    >
    > Your best bet would be to add a clause to your script to check whether the linked binary exists at the destination path (if it the link failed or the link was killed by Xcode [e.g. because the build was cancelled] then Xcode will have removed any partially-linked binary), and skip the meat of your script if it’s missing.  You may wish to have the script emit an error message or return a nonzero exit code in that case.

    Thanks, Michael,

    You're correct, I have it set to continue building.  Your idea sounds fine.

    -Howard
  • >>> In Xcode 3.2.6, I've got a script phase that runs after everything else is done, but it always runs even if there is a compile or link error prior to that.  I don't want to have the compiler stop on build errors, but I also don't want to execute [at least a portion of] my script, because it will always fail if the link hasn't been performed or hasn't succeeded.  I don't see any way to control the execution of the script in this manner, though.  Is there a variable that gets set when linking has succeeded (or failed) that I can use to tell my script to skip over all or part of it?
    >>
    >>
    >> If you’ve turned on the “Continue Building After Errors” preference (which it sounds like you have), then Xcode doesn’t provide any support for what you’re trying to do.
    >>
    >> Your best bet would be to add a clause to your script to check whether the linked binary exists at the destination path (if it the link failed or the link was killed by Xcode [e.g. because the build was cancelled] then Xcode will have removed any partially-linked binary), and skip the meat of your script if it’s missing.  You may wish to have the script emit an error message or return a nonzero exit code in that case.
    >
    > Thanks, Michael,
    >
    > You're correct, I have it set to continue building.  Your idea sounds fine.
    >

    Hmmm… well, the problem is, Xcode doesn't remove the target bundle unless I do a clean first.  I'm checking for the existence of ${TARGET_BUILD_DIR}/${PRODUCT_NAME).${WRAPPER_EXTENSION}.  It's always there unless I do a clean, (as is the binary inside its Contents/MacOS folder).  Is there some other (intermediate?) product I should check for?

    Thanks,
    Howard
  • >>>> In Xcode 3.2.6, I've got a script phase that runs after everything else is done, but it always runs even if there is a compile or link error prior to that.  I don't want to have the compiler stop on build errors, but I also don't want to execute [at least a portion of] my script, because it will always fail if the link hasn't been performed or hasn't succeeded.  I don't see any way to control the execution of the script in this manner, though.  Is there a variable that gets set when linking has succeeded (or failed) that I can use to tell my script to skip over all or part of it?
    >>>
    >>>
    >>> If you’ve turned on the “Continue Building After Errors” preference (which it sounds like you have), then Xcode doesn’t provide any support for what you’re trying to do.
    >>>
    >>> Your best bet would be to add a clause to your script to check whether the linked binary exists at the destination path (if it the link failed or the link was killed by Xcode [e.g. because the build was cancelled] then Xcode will have removed any partially-linked binary), and skip the meat of your script if it’s missing.  You may wish to have the script emit an error message or return a nonzero exit code in that case.
    >>
    >> Thanks, Michael,
    >>
    >> You're correct, I have it set to continue building.  Your idea sounds fine.
    >>
    >
    > Hmmm… well, the problem is, Xcode doesn't remove the target bundle unless I do a clean first.  I'm checking for the existence of ${TARGET_BUILD_DIR}/${PRODUCT_NAME).${WRAPPER_EXTENSION}.  It's always there unless I do a clean, (as is the binary inside its Contents/MacOS folder).  Is there some other (intermediate?) product I should check for?
    >
    Even doing a clean does not help, because the destination bundle is created in order to copy the resources, info.plist, etc., to it, prior to the script phase running.

    Is there something else I can check besides the existence of the product to see if the compile and link phases completed without error?

    -Howard
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today