A few functions to help automate installation and validation of the XCode developer tools
Created
February 28, 2023 13:53
-
-
Save tcarrio/401664e923af9130052f21b2cb299847 to your computer and use it in GitHub Desktop.
XCode automations
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 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