Last active
December 31, 2015 10:39
-
-
Save randombrein/5a14bc9466f825d58f20 to your computer and use it in GitHub Desktop.
Xcode bump-version script using 'xcodebuild -showBuildSettings'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function get_env_val { | |
path=$(xcode-select -print-path) | |
var=$($path/usr/bin/xcodebuild -showBuildSettings | sed -n -e 's/'"$1"' = \(.*\)/\1/p') | |
echo $var | |
} | |
SRCROOT=$(get_env_val "SRCROOT") | |
TARGETNAME=$(get_env_val "TARGETNAME") | |
PROJECT_DIR=$(get_env_val "PROJECT_DIR") | |
INFOPLIST_FILE=$(get_env_val "INFOPLIST_FILE") | |
oldBuildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}") | |
#CFBundleVersion (build number) must be integer! | |
buildNumber=$(($oldBuildNumber + 1)) | |
echo "bumping version..." | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${INFOPLIST_FILE}" | |
echo "bumped: $oldBuildNumber -> $buildNumber" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment