我的 info.plist 文件中有两个值,比如 string1 和 string 2
我想添加一个运行脚本来比较两个值并在值不相等时调用构建错误。
我是脚本新手,我遇到了一些语法问题,这是我到目前为止所取得的成就
set string1 to $(/usr/libexec/PlistBuddy -c "Print string1" "${PROJECT_DIR}/${INFOPLIST_FILE}")
set string2 to $(/usr/libexec/PlistBuddy -c "Print string2" "${PROJECT_DIR}/${INFOPLIST_FILE}")
echo string1
echo string2
if string1 = string2 then
echo "no errors" else
echo "generate build error in xcode"
非常感谢任何指点。 谢谢
最佳答案
您遇到的错误是因为 if else 循环中的错误语法和变量的设置值
# Basic value settings to the variable from the command execution
string1=$(/usr/libexec/PlistBuddy -c "Print string1" "${PROJECT_DIR}/${INFOPLIST_FILE}")
string2=$(/usr/libexec/PlistBuddy -c "Print string2" "${PROJECT_DIR}/${INFOPLIST_FILE}")
#Below is the basic if else loop in shell scripting with string comparison
if [ "$string1" = "$string2" ]
then
echo "EQUAL"
else
echo "NOT EQUAL"
fi
希望这对您有所帮助。
关于xcode - 使用运行脚本比较来自 info.plist 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21823702/