When using Xcode, kill $PPID
is not a solution, as I was commenting to Farcaller.
My solution is to have the pre-action script generate a header file (e.g. SchemePreActions.h) and make it empty for normal situation, and include it into your code (e.g. into AppDelegate.m).
This way, if you want the pre-actions script to report an error, put there a #error
line, like in this real-world example:
if [ $CONFIGURATION == Debug ]; then
echo "#error AppStore builds must not be in debug configuration" >> SchemePreActions.h
fi
Xcode will report this error very nicely.
It is recommended to have the generated file ignored by git.
As a tip I will add that my pre-actions script always starts with these lines:
echo "//auto-generated. no need to commit" > SchemePreActions.h
echo "#define SCHEME_${SCHEME_NAME}" >> SchemePreActions.h
echo "#define SCHEME_NAME @\"${SCHEME_NAME}\"" >> SchemePreActions.h
if [[ ${SCHEME_NAME} =~ "_PROD" ]]; then
echo "#define PRODUCTION" >> SchemePreActions.h
fi
This way, by including SchemePreActions.h, my code can test to see if running under a specific scheme.
pre-actions
orpost-actions
scripts. I useAppleScript
to showDialog
orNotification
for it. stackoverflow.com/a/63655906/4026902