ios build+1脚本
#!/bin/sh
# ******************************************************
# ******************************************************
#
# 每次编译后是否Build自动加1,
# 可以修改该常量的值,以决定编译后还是打包后Build自动加1
# # 0: 每次打包后Build自动加1
# # 1: 每次编译后Build自动加1
DEBUG_ENVIRONMENT_SYMBOL=1
#
#
# 编译或打包环境的标志,默认为编译环境
configuration_flag="Debug"
if [ $DEBUG_ENVIRONMENT_SYMBOL -eq 0 ]; then
configuration_flag="Release"
fi
# 打印当前Xcode的环境配置
echo "The current environment configuration for Xcode is: $CONFIGURATION"
if [ $configuration_flag == "${CONFIGURATION}" ]; then
echo "The build version number needs to be increased."
build_version=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${INFOPLIST_FILE}")
# 判断读取出来的build_version变量是否为 $(CURRENT_PROJECT_VERSION) :
# 若是,则从 CURRENT_PROJECT_VERSION 读取Build版本号,然后+1;
# 若不是,则读取出来的build_version变量即为Build版本号,直接+1;
if [ $build_version == '$(CURRENT_PROJECT_VERSION)' ]; then
build_version=${CURRENT_PROJECT_VERSION}
fi
build_version=$(($build_version + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build_version" "${INFOPLIST_FILE}"
else
echo "The build version number does not need to be increased."
fi
本文地址:https://blog.csdn.net/a787188834/article/details/109639333