Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
check Xcode version
# http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format/4025065#4025065
# 0: =, 1: >, 2: <
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
REQUIRED_VERSION=6.1
VERSION=`xcodebuild -version | head -n 1 | cut -d ' ' -f 2`
vercomp $VERSION $REQUIRED_VERSION
if [[ $? == 2 ]]; then
# http://briksoftware.com/blog/?p=120
echo "error: required Xcode version ${REQUIRED_VERSION}"
fi
if [[ $XCODE_VERSION_MINOR < 0610 ]]; then
echo "error: required Xcode version 6.1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.