iOS编译自动升级版本号脚本

时间:2024-04-02 20:05:47

版权申明:

本文原创首发于以下网站,您可以*转载,但必须加入完整的版权声明

博客园:https://www.cnblogs.com/MogooStudio/

csdn博客:https://blog.csdn.net/nmjkl001/

知乎:https://www.zhihu.com/people/MogooStudio/

简书:https://www.jianshu.com/u/9547c81ca54e

segmentfault:https://segmentfault.com/u/mogoostudio

使用方法

  • Shell代码设置到xcode运行脚本里
  • 在每次成功构建后版本号会改变

Shell代码

#!/usr/bin/env bash

echo $CONFIGURATION

if [ $CONFIGURATION == Release ]; then
echo " Bumping build number... " #!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
if [ "${buildNumber}" == "" ]; then
echo 2
fi var1=${buildNumber##*.}
var1=$(($var1 + 1))
var2=${buildNumber%.*}
buildNumber=${var2}.${var1} /usr/libexec/PlistBuddy -c "Set CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
echo " Bumped build number to $buildNumber " else
echo $CONFIGURATION " build - Not bumping build number. " fi

我的联系方式:

QQ:2161044579

邮箱:mogoostudio@outlook.com

Github:https://github.com/MogooStudio