我的 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"
Run Code Online (Sandbox Code Playgroud)
任何指针都受到高度赞赏。谢谢
由于 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
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。