Skip to content

Instantly share code, notes, and snippets.

@tcarrio
Created February 28, 2023 13:53
Show Gist options
  • Save tcarrio/401664e923af9130052f21b2cb299847 to your computer and use it in GitHub Desktop.
Save tcarrio/401664e923af9130052f21b2cb299847 to your computer and use it in GitHub Desktop.
XCode automations

xcode.sh

A few functions to help automate installation and validation of the XCode developer tools

⚠️ Still a work in progress

#!/usr/bin/env sh
function automateInstaller() {
osascript <<EOD
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell
EOD
}
function installXCode() {
xcode-select --install > /dev/null 2>&1
if [ 0 -ne $? ]; then
sleep 1
automate_installer
else
echo "Command Line Developer Tools are already installed!"
fi
}
function closeInstaller() {
return_code=1
while [ $return_code -gt 0 ]; do
sleep 1
osascript <<EOD
tell application "System Events"
tell application "Install Command Line Developer Tools"
click button "Cancel" of window "License Agreement"
end tell
end tell
EOD
return_code="$?"
done
}
function isXCodeInstalled() {
xcode-select --install # >/dev/null 2>&1
return_code=$?
if [ 0 -eq $return_code ]; then
closeInstaller
# failure if it is not installed
return 1
else
# success if it is installed
return 0
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment