问题
I have an iOS application that is using the Agentry framework to define the Agentry server URL to connect. The agentryServerURL parameter is included in a separate branding.plist file as per the SAP specs. What I am trying to do is tie my iOS schemes for the different environments to a pre-build action in order to change the Agentry URL value.
Here is my current script but it is not working.
#!/bin/sh
plist=$SRCROOT"/branding.plist"
if [ ${CONFIGURATION} = "DEV" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpdevURL" "$plist"
if [ ${CONFIGURATION} = "QA" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpqaURL" "$plist"
if [ ${CONFIGURATION} = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpprodURL" "$plist"
fi
This is the first time I have written a pre-build script so it is likely something with my syntax
回答1:
Try this:
#!/bin/sh
plist="${SRCROOT}/branding.plist"
if [ "${CONFIGURATION}" == "DEV" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpdevURL" "$plist"
elif [ "${CONFIGURATION}" == "QA" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpqaURL" "$plist"
elif [ "${CONFIGURATION}" == "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpprodURL" "$plist"
fi
来源:https://stackoverflow.com/questions/46307682/ios-pre-build-action-to-change-plist-value-based-on-scheme