Last active
December 19, 2015 02:28
-
-
Save jcayzac/5882969 to your computer and use it in GitHub Desktop.
Detect latest available Xcode version
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
#!/usr/bin/env bash | |
latest_xcode() { | |
local XcodePath XcodeVersion XcodeVersionMajor XcodeVersionMinor | |
for XcodePath in /Applications/Xcode*.app | |
do | |
XcodeVersion="$(defaults read "${XcodePath}/Contents/Info" CFBundleVersion)" | |
XcodeVersionMajor=${XcodeVersion%%.*} | |
if [ "$XcodeVersion" == "$XcodeVersionMajor" ] | |
then | |
XcodeVersionMinor=0 | |
else | |
XcodeVersionMinor=${XcodeVersion##*.} | |
fi | |
[ -d "${XcodePath}/Contents/Developer" ] && printf "%08i%08i:%s\n" "$XcodeVersionMajor" "$XcodeVersionMinor" "${XcodePath}/Contents/Developer" | |
done | sort -r | head -n 1 | cut -d: -f2 | |
} | |
export DEVELOPER_DIR="$(latest_xcode)" | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment