I am trying to implement the answer here:
Better way of incrementing build number?
but cannot get it to work properly. It fails with error 2 saying "No build number in plist"
But if I put a build number in my plist, the script clears it on the next build, then the same thing happens all over again.
Any ideas?
Here's how I increment build numbers:
In the Target > Summary tab, set the initial build #
Then use this script to increment the build number:
#!/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"
or if you want build numbers in hex:
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$((0x$buildNumber))
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%04X" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
My solution is the following:
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(echo $buildNumber | sed 's/0*//')
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%04d" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
Using sed to remove leading zeroes, incrementing the value and printing it back in the plist file using a four-digit-zero-padded number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With