Last active
May 15, 2020 20:50
-
-
Save ohnit/280bc7235e6946b167febe0d130abb0f to your computer and use it in GitHub Desktop.
Change Xcode Build and Version numbers for all targets
This file contains hidden or 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 | |
# See "To Use" instructions at at bottom of file | |
bumpBuildForSchemeTo() { | |
local scheme=$1 | |
local buildNumber=$2 | |
filePath=$(xcodebuild -workspace "$workspace" -scheme "$scheme" -configuration Debug -showBuildSettings | grep "^\s*INFOPLIST_FILE" | awk '{print $3}') | |
echo "Bumping build versions for $scheme to $buildNumber" | |
incrementBundleVersionAtPathTo "$filePath" "$buildNumber" | |
} | |
incrementBundleVersionAtPathTo() { | |
local plistPath=$1 | |
local buildNumber=$2 | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$plistPath" | |
} | |
incrementAllBundleVersions() { | |
schemes=() | |
while IFS='' read -r line; do | |
line=$(sed -e 's/^"//' -e 's/"$//' <<<"$line") | |
schemes+=("$line") | |
done < <(xcodebuild -list -json | jq '.project.schemes[]') | |
echo "Schemes to be bumped:" | |
for scheme in "${schemes[@]}"; do | |
echo " $scheme" | |
done | |
echo "" | |
echo "Bumping build versions to $1" | |
for scheme in "${schemes[@]}"; do | |
bumpBuildForSchemeTo "$scheme" "$1" | |
done | |
echo "" | |
} | |
workspace=$(basename "$(find . -name "*.xcworkspace" | head -n 1)") | |
if [ $# -eq 1 ] | |
then | |
incrementAllBundleVersions "$1" | |
else | |
echo "Error: expecting one argument, the build number" | |
echo "To Use: ./bumpBuildTo <some number>" | |
echo "Run in same directory as workspace" | |
fi |
This file contains hidden or 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 | |
# See "To Use" info at bottom for instructions | |
changeVersionForSchemeTo() { | |
local scheme=$1 | |
local version=$2 | |
filePath=$(xcodebuild -workspace "$workspace" -scheme "$scheme" -configuration Debug -showBuildSettings | grep "^\s*INFOPLIST_FILE" | awk '{print $3}') | |
echo "Bumping build versions for $scheme to $version" | |
changeVersionAtPathTo "$filePath" "$version" | |
} | |
changeVersionAtPathTo() { | |
local plistPath=$1 | |
local version=$2 | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" "$plistPath" | |
} | |
changeAllVersions() { | |
schemes=() | |
while IFS='' read -r line; do | |
line=$(sed -e 's/^"//' -e 's/"$//' <<<"$line") | |
schemes+=("$line") | |
done < <(xcodebuild -list -json | jq '.project.schemes[]') | |
echo "Schemes to be changed:" | |
for scheme in "${schemes[@]}"; do | |
echo " $scheme" | |
done | |
echo "" | |
echo "Changing versions to $1" | |
for scheme in "${schemes[@]}"; do | |
changeVersionForSchemeTo "$scheme" "$1" | |
done | |
echo "" | |
} | |
workspace=$(basename "$(find . -name "*.xcworkspace" | head -n 1)") | |
if [ $# -eq 1 ] | |
then | |
changeAllVersions "$1" | |
else | |
echo "Error: expecting one argument, the version number" | |
echo "To Use: ./bumpVersionTo <some string>" | |
echo "Run in same directory as workspace" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment