简体   繁体   中英

"Set :CFBundleVersion $buildNumber" not setting incremented build number in XCode 12

I have added the following script to increment my build number in XCode 12 under build phases

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${INFOPLIST_FILE}"

But the build number is not getting incremented. When I used an alternative script, the build number was incrementing incorrectly and ranging between 0000 to 0006. I don't really want the leading zeros but at least this script was changing the build which is why I am listing it here.

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%04d" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

Can someone tell me what's the issue with the first script? It used to work in the past. And I have ensured that xcode is pointing to the correct Info.plist file.

Try this:

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}"

AND! MAKE SURE THAT (BundleVersion) contains NUMBER!

screenshot xcode

Run this script before:

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion 1" "${PROJECT_DIR}/${INFOPLIST_FILE}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM