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)

查看:114
本文介绍了iOS:如何在 Xcode 11 中自动升级我的 CFBundleVersion 和我的 CFBundleShortVersionString?(我的旧脚本不再起作用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本升级了我的版本(0.01 x 0.01)和我的构建(1 x 1).它不再适用于 Xcode 11.

这是我的脚本:

 #!/bin/bashrm -rf 构建版本=$(/usr/libexec/PlistBuddy -c "打印 CFBundleShortVersionString" "$INFOPLIST_FILE")版本=$(echo "scale=2; $Version + 0.01" | bc)Build=$(/usr/libexec/PlistBuddy -c "打印 CFBundleVersion" "$INFOPLIST_FILE")建造=$($建造+1)/usr/libexec/PlistBuddy -c "设置:CFBundleVersion $Build"$INFOPLIST_FILE"if [ "${CONFIGURATION}" = "发布"];然后/usr/libexec/PlistBuddy -c "设置 :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"菲

这是我现在想在 Xcode 中构建或存档时收到的错误消息:

<块引用>

详情

未能安装请求的应用程序
域:NSPOSIXErrorDomain代码:22
失败原因:应用程序的 Info.plist 不包含 CFBundleShortVersionString.
恢复建议:确保您的包包含 CFBundleShortVersionString.
用户信息:{
bundleURL = "file:///Users/olosta/Library/Developer/Xcode/DerivedData/Formbox-cxaxehrhmxqaqabbijmxvasgmhwn/Build/Products/Debug-iphonesimulator/Formbox_Renault_BusinessDays.app/";
}

我检查了 但如果我检查我的信息.plist 手动打开,两个值都是空的

 CFBundleVersion<字符串></字符串><key>CFBundleShortVersionString</key><字符串></字符串>

如果我直接在 plist 中手动填充它们,它可以工作,但 Xcode 中的值似乎不再存储在该字段中?你怎么看?

解决方案

这里是完整的脚本.我尝试过新旧项目.

 #!/bin/bashrm -rf 构建Build=$(/usr/libexec/PlistBuddy -c "打印 CFBundleVersion" "$INFOPLIST_FILE")版本=$(/usr/libexec/PlistBuddy -c "打印 CFBundleShortVersionString" "$INFOPLIST_FILE")if [ "${Build}" = "" ];然后/usr/libexec/PlistBuddy -c "设置:CFBundleVersion 1" "$INFOPLIST_FILE"别的Build=$(/usr/libexec/PlistBuddy -c "打印 CFBundleVersion" "$INFOPLIST_FILE")Build=$(echo "scale=0; $Build + 1" | bc)/usr/libexec/PlistBuddy -c "设置:CFBundleVersion $Build" "$INFOPLIST_FILE"菲if [ "${Version}" = "" ];然后/usr/libexec/PlistBuddy -c "设置 :CFBundleShortVersionString 1.00" "$INFOPLIST_FILE"别的版本=$(/usr/libexec/PlistBuddy -c "打印 CFBundleShortVersionString" "$INFOPLIST_FILE")版本=$(echo "scale=2; $Version + 0.01" | bc)if [ "${CONFIGURATION}" = "发布"];然后/usr/libexec/PlistBuddy -c "设置 :CFBundleShortVersionString $Version" "$INFOPLIST_FILE"菲菲


为了完成解决方案,我在 plist 中添加了该键.我通过以下方式更改了现有值:

CFBundleShortVersionString<string>1.00</string><key>CFBundleVersion</key><字符串>1</字符串>

I have a script that upgraded my version (0.01 by 0.01) and my build (1 by 1). It doesn't work anymore with the Xcode 11.

Here is my script:

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

Here is the Error message I have now when I want to build or archive in 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/";
}

I checked that ticket, but it doesn't help me for the script

If I go in Xcode/General/Identity, I can see that the "Version" and the "Build" are filled in the Xcode, but if I check my info.plist by manually opening it, both values are empty

   <key>CFBundleVersion</key>               <string></string>    
   <key>CFBundleShortVersionString</key>    <string></string>

If I fill them manually directly in the plist, it works but it seems that the values from Xcode are not stored in that fields anymore? What do you think?

解决方案

Here is the complete script. I tried it with old and new projects.

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

EDIT:
For completing the solution, I added that keys in the plist. I changed the existing values by:

<key>CFBundleShortVersionString</key>
    <string>1.00</string>
    <key>CFBundleVersion</key>
    <string>1</string>

这篇关于iOS:如何在 Xcode 11 中自动升级我的 CFBundleVersion 和我的 CFBundleShortVersionString?(我的旧脚本不再起作用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆