欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

ios build+1脚本

程序员文章站 2022-07-04 19:32:25
#!/bin/sh# ******************************************************## Copyright 2015-2020 BTStudio. All rights reserved.## Author : Wangzhi# Last modified : 2020-08-12 14:30# Email : wzqsyk@126.com# Description : 每次编译或打包后Build自动加......

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

相关标签: app苹果iOS类 ios