0 Replies
      Latest reply on Feb 13, 2020 5:55 AM by MagnusEffect
      MagnusEffect Level 1 Level 1 (0 points)

        Is there a way to have the Xcode schema pre-action script abort the build?

         

        I do realize that if I have my script execute "exit 1" in the "Build" stage, that the failed execution state will be identified and stop the build process at the failure point.  I can NOT put my script in the "Build" stage because my validation needs to run prior to the "Dependencies" step, which is not allowed.  So I need to run it in the pre-actions stage; unless there is a different solution.

         

        The problem I am trying to solve is that I want to prevent an attempted build in Adhoc and Distribution when the "Automatically manage signing" flag is set because we are not using automatic signing and if the project has this set it will invalidate our profile during the attempted build.  If I try to do a simple run script within the build, my script (the validation check) happens after the signing has been attempted and invalidates the certificate, which is too late. So, I'm trying to exit the build if this case exists because I don't have access to reenable the profile and is a process to get it fixed.

         

        Here is my Build | Pre-actions | Run Script:

        exec > ${PROJECT_DIR}/prebuild.log 2>&1

        ${SRCROOT}/Build-Phases/pre-action-script.sh

         

        Here is my external script:

        echo "Configuration: $CONFIGURATION"

        echo "Code Sign Style: $CODE_SIGN_STYLE"

        if [ $CONFIGURATION = "Adhoc" ] || [ $CONFIGURATION = "Distribution" ]; then

        if [ $CODE_SIGN_STYLE = "Manual" ]; then

           echo "SUCCESS"

        else

           echo "FAILURE"

           exit 1

        fi

        fi

        exit 0

         

        I have confirmed my results in the prebuild.log, so I know it is catching what I've identified as a failure and exiting with 1, but the build still continues to run; invalidating the profile.

         

        Is there another way to do this?  I have multiple members on my team, which is why I am attempting to put this validation step in to prevent inadvertently making our profile invalid.

         

        I guess if I looked on this at a higher view I would question how the developers, who don't have the access to maintain the profiles, have the power to break the profile when they don't have the power to fix it, but that's not my topic here   I'm just trying to find a way to prevent human error during the build.

         

        Thank you!