In the Build Settings of my project's target, I have preprocessor Macros configured as following:
Debug FILE_SHARE = 1
Adhoc FILE_SHARE = 1
Release FILE_SHARE = 2
I want to change the UIFileSharingEnabled
flag based on those settings values in a script, something like the following:
#!/bin/bash
if [${buildSettings}/${GCC_PREPROCESSOR_DEFINITIONS}/${FILE_SHARE} = 1 ]; then
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled YES" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
else
usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled NO" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
I know ${buildSettings}/${GCC_PREPROCESSOR_DEFINITIONS}/${FILE_SHARE} = 1
is the wrong syntax, but I cannot figure out what should be right syntax.
The "User-Defined Build Settings" are also part of the environment when the run script is executed, so the following should work:
if [ ${FILE_SHARE} = 1 ]; then
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled YES" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
else
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled NO" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
Edit: I have misread your question, the above answer applies to "User-Defined Build Settings", not to preprocessor macros.
The following script uses the regular expression matching feature of expr
to extract the value of the FILE_SHARE preprocessor macro:
val=`expr "$GCC_PREPROCESSOR_DEFINITIONS" : ".*FILE_SHARE=\([0-9]*\)"`
if [ $val = 1 ]; then
...
else
...
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With