我正在尝试使用以下脚本自动增加内部版本号:

#!/bin/bash
# Auto Increment Version Script
buildPlist="Project-Info.plist"
buildVersion=$(/usr/libexec/PlistBuddy -c "Print CFBuildVersion" $buildPlist)
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBuildNumber" $buildPlist)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBuildNumber $buildNumber" $buildPlist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildVersion.$buildNumber" $buildPlist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildVersion.$buildNumber" $buildPlist

但是,我的 buildPlist 文件名有一个空格,即。 "Foo App.plist"这将导致脚本失败。任何快速修复?

谢谢

最佳答案

问题解决了。

#!/bin/bash
# Auto Increment Version Script
echo "${PROJECT_DIR}/${INFOPLIST_FILE}"
buildVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"

关于使用 info.plist 的 xCode 构建脚本,名称中有空格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7721227/

10-10 12:34