iOS Pre-build action to change plist value based on Scheme

不打扰是莪最后的温柔 提交于 2019-12-13 03:48:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!