有时候,为了省事,我们可以配置build号自增长,现记录如下:
在Build中,填写
Build and Version set By Build Phase。
![img_112c1b2d9e17769fa765443500bdf895.png](https://yqfile.alicdn.com/img_112c1b2d9e17769fa765443500bdf895.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
切换到 Build Phases 下:
![img_a5fee550ac858b2fb8418fc3ef46d816.png](https://yqfile.alicdn.com/img_a5fee550ac858b2fb8418fc3ef46d816.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
点击左上角的 + 号:
![img_d851c7da00e0b6a34cc62d8872abe5d0.png](https://yqfile.alicdn.com/img_d851c7da00e0b6a34cc62d8872abe5d0.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
选择 New Run Script Phase
![img_fd1a15bc203bf5959c863943f8c7126a.png](https://yqfile.alicdn.com/img_fd1a15bc203bf5959c863943f8c7126a.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
双击 修改名字:
![img_73f42d4c8fa54affa038b0bea988bdeb.png](https://yqfile.alicdn.com/img_73f42d4c8fa54affa038b0bea988bdeb.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
![img_5fa958bfb123d164ae976a8445b2ddb8.png](https://yqfile.alicdn.com/img_5fa958bfb123d164ae976a8445b2ddb8.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
点击左边的三角符号,展开配置:
![img_c56d1d00ff5f9f09a9e74dd82d6c55a0.png](https://yqfile.alicdn.com/img_c56d1d00ff5f9f09a9e74dd82d6c55a0.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
现在写脚本:
"${SRCROOT}/Scripts/set_buildnumber.sh"
再次新建脚本:
![img_514731acad6e92901743c8cebb611b7e.png](https://yqfile.alicdn.com/img_514731acad6e92901743c8cebb611b7e.png?x-oss-process=image/resize,w_1400/format,webp)
image.png
注意:
这里的自增长方式build号是根据当前git的分支以及上传次数等组合起来的,所以一定要有git地址。
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName-$appBuildOfCommit" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"