關於 軟體版本號 -wiki
Xcode 8/9 中自動增加 build 號碼
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}"
Build Phases / [CP] Copy Pods Resources
然後在 Xcode 每執行一次(Build),Build 號碼就會自動加一
這數字讓你知道專案從建立一直到完成,總共 Build幾次
Swift 讀取 Version / Build 的方法:
let dictionary = Bundle.main.infoDictionary!
let version = dictionary["CFBundleShortVersionString"] as! String
let build = dictionary["CFBundleVersion"] as! String
print("version=\(version) build=\(build)")
參考
Auto-Incrementing Build Numbers in Xcode