仅在ARCHIVE期间Xcode-Increment内部版本号? [英] Xcode-Increment build number only during ARCHIVE?

查看:67
本文介绍了仅在ARCHIVE期间Xcode-Increment内部版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了其他一些文章,这些文章显示了如何添加脚本以通过脚本增加内部版本号:

I have found a few other posts that show how to add a script to increment the build number with a script:

增加内部版本号的更好方法?

Xcode项目的内部版本号"

可以Xcode插入版本

但是我要做的是,仅在使用ARCHIVE时(之前和之后)才增加内部版本号.

But what I want to do, is only increase the build number when I use ARCHIVE (both before and after).

示例: 如果当前内部版本号为21,则当我选择产品">存档"时,内部版本号将增加到22,它将经历其构建过程并创建内部版本号为22的存档"文件,然后完成归档,它将内部版本号增加到23.

Example: If current build number is 21, then when I choose Product > Archive the build number will be increased to 22, it will go through its process of building and creating the Archive file with the build number of 22, and then when it is finished archiving, it will increase the build number to 23.

推荐答案

添加以下脚本,如您发布的第一个链接中列出的示例所示,但请执行两次.在构建开始时一次,在构建结束时一次:

Add the following script, as in the example listed in the first link that you posted, BUT do it twice. Once at the beginning of the build and once at the end:

if [ $CONFIGURATION == Release ]; then
    echo "Bumping build number..."
    plist=${PROJECT_DIR}/${INFOPLIST_FILE}

# increment the build number (ie 115 to 116)
    buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
    if [[ "${buildnum}" == "" ]]; then
        echo "No build number in $plist"
        exit 2
    fi

    buildnum=$(expr $buildnum + 1)
    /usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
    echo "Bumped build number to $buildnum"

else
    echo $CONFIGURATION " build - Not bumping build number."
fi

非常感谢您在问题中链接到的问题的作者,这些信息为我提供了开始使用此答案的信息!

Many thanks to the authors of the questions that you have linked to in your question for the information that got me started on this answer!

这篇关于仅在ARCHIVE期间Xcode-Increment内部版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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