iOS 根据 Scheme 更改 plist 值的预构建操作

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

我有一个 iOS 应用程序正在使用代理框架来定义要连接的代理服务器 URL。根据 SAP 规范,agentryServerURL 参数包含在单独的 branding.plist 文件中。我想要做的是将我针对不同环境的 iOS 方案与预构建操作联系起来,以更改 Agentry URL 值。

这是我当前的脚本,但它不起作用。

#!/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

这是我第一次编写预构建脚本,所以它可能符合我的语法

试试这个:

#!/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