iOS: 如何在 Xcode 11 中自动升级我的 CFBundleVersion 和我的 CFBundleShortVersionString? (我的旧脚本不再起作用了)
iOS: How to upgrade my CFBundleVersion and my CFBundleShortVersionString automatically in Xcode 11? (My old script doesn't work anymore)
我有一个脚本可以升级我的版本(0.01 到 0.01)和我的构建(1 到 1)。它不再适用于 Xcode 11.
这是我的脚本:
#!/bin/bash
rm -rf build
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
Version=$(echo "scale=2; $Version + 0.01" | bc)
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Build=$($Build + 1)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $Build"
"$INFOPLIST_FILE"
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"
fi
这是我现在想要在 Xcode 中构建或存档时收到的错误消息:
Details
Failed to install the requested application
Domain: NSPOSIXErrorDomain
Code: 22
Failure Reason: The application's Info.plist does not contain CFBundleShortVersionString.
Recovery Suggestion: Ensure your bundle contains a CFBundleShortVersionString.
User Info: {
bundleURL = "file:///Users/olosta/Library/Developer/Xcode/DerivedData/Formbox-cxaxehrhmxqaqabbijmxvasgmhwn/Build/Products/Debug-iphonesimulator/Formbox_Renault_BusinessDays.app/";
}
我检查过,但它对脚本没有帮助
如果我进入 Xcode/General/Identity,我可以看到 "Version" 和 "Build" 填充在 Xcode、 中,但是如果我通过手动打开检查我的info.plist,两个值都是空的
<key>CFBundleVersion</key> <string></string>
<key>CFBundleShortVersionString</key> <string></string>
如果我直接在 plist 中手动填充它们,它可以工作,但似乎 Xcode 中的值不再存储在该字段中?你怎么看?
您可以尝试:
versionNumber="$MARKETING_VERSION"
buildNumber="$CURRENT_PROJECT_VERSION"
来自
这是完整的脚本。我尝试了新旧项目。
#!/bin/bash
rm -rf build
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
if [ "${Build}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion 1" "$INFOPLIST_FILE"
else
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Build=$(echo "scale=0; $Build + 1" | bc)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $Build" "$INFOPLIST_FILE"
fi
if [ "${Version}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString 1.00" "$INFOPLIST_FILE"
else
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
Version=$(echo "scale=2; $Version + 0.01" | bc)
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"
fi
fi
编辑:
为了完成解决方案,我在 plist 中添加了该键。我通过以下方式更改了现有值:
<key>CFBundleShortVersionString</key>
<string>1.00</string>
<key>CFBundleVersion</key>
<string>1</string>
我有一个脚本可以升级我的版本(0.01 到 0.01)和我的构建(1 到 1)。它不再适用于 Xcode 11.
这是我的脚本:
#!/bin/bash
rm -rf build
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
Version=$(echo "scale=2; $Version + 0.01" | bc)
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Build=$($Build + 1)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $Build"
"$INFOPLIST_FILE"
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"
fi
这是我现在想要在 Xcode 中构建或存档时收到的错误消息:
Details
Failed to install the requested application
Domain: NSPOSIXErrorDomain Code: 22
Failure Reason: The application's Info.plist does not contain CFBundleShortVersionString.
Recovery Suggestion: Ensure your bundle contains a CFBundleShortVersionString.
User Info: {
bundleURL = "file:///Users/olosta/Library/Developer/Xcode/DerivedData/Formbox-cxaxehrhmxqaqabbijmxvasgmhwn/Build/Products/Debug-iphonesimulator/Formbox_Renault_BusinessDays.app/";
}
我检查过
如果我进入 Xcode/General/Identity,我可以看到 "Version" 和 "Build" 填充在 Xcode、
<key>CFBundleVersion</key> <string></string>
<key>CFBundleShortVersionString</key> <string></string>
如果我直接在 plist 中手动填充它们,它可以工作,但似乎 Xcode 中的值不再存储在该字段中?你怎么看?
您可以尝试:
versionNumber="$MARKETING_VERSION"
buildNumber="$CURRENT_PROJECT_VERSION"
来自
这是完整的脚本。我尝试了新旧项目。
#!/bin/bash
rm -rf build
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
if [ "${Build}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion 1" "$INFOPLIST_FILE"
else
Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
Build=$(echo "scale=0; $Build + 1" | bc)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $Build" "$INFOPLIST_FILE"
fi
if [ "${Version}" = "" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString 1.00" "$INFOPLIST_FILE"
else
Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
Version=$(echo "scale=2; $Version + 0.01" | bc)
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"
fi
fi
编辑:
为了完成解决方案,我在 plist 中添加了该键。我通过以下方式更改了现有值:
<key>CFBundleShortVersionString</key>
<string>1.00</string>
<key>CFBundleVersion</key>
<string>1</string>