tags: Xcode, 日常技巧
今天打包发版时, 忽然想到为啥我要手动去改版本号呢?
于是我 google 了一下, 找到一个解决办法, 是通过添加一个脚本的方式实现。
原文链接 Increase the build number while Archiving in Xcode
以下是精简版说明:
-
TARGETS
-> [your project] ->Build Phases
->+
- Select
New Run Script Phase
- Copy this entire script in the provided blank space.
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
- Check the
Run script only when installing
item. If you want this script to increment build number only while archiving project. - Uncheck the
Run script only when installing
item. If you want to increment build number every time you run the project.
网友评论