Last active
November 22, 2023 18:26
-
-
Save ryanmaclean/e574a8a0cc16db2cafd1 to your computer and use it in GitHub Desktop.
Accept Xcode License on the Command Line
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
# Run using "sudo accept_xcode_license.sh" | |
# | |
# Solving the OSX Yosemite Xcode Command Line Tools Licensing problem | |
# for multiple updates in order to script post-install tasks. | |
# Typical error reads after running "xcode-select --install" when setting up | |
# Homebrew is: "Agreeing to the Xcode/iOS license requires admin priviledges, | |
# please re-run as root via sudo" | |
# | |
# CREDIT: | |
# Based on a tip found at http://krypted.com/mac-os-x/licensing-the-xcode-command-line-tools/ | |
# Also using the code found here: http://stackoverflow.com/questions/26125036 | |
!/usr/bin/expect | |
set timeout 5 | |
spawn sudo xcodebuild -license | |
expect { | |
"By typing 'agree' you are agreeing" { | |
send "agree\r\n" | |
} | |
"Software License Agreements Press 'space' for more, or 'q' to quit" { | |
send " "; | |
exp_continue; | |
} | |
timeout { | |
send_user "\nTimeout 2\n"; | |
exit 1 | |
} | |
} | |
expect { | |
timeout { | |
send_user "\nFailed\n"; | |
exit 1 | |
} | |
} |
Thank Andy, with that line, specifiying location of Xcode, and then accepting works brilliantly.
sudo xcodebuild -license accept
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Perfect guys! Thank you!
Just reorder...
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
Thanks..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ryan - can you check my fork out? I added execute bit to the script and corrected so that the
expect
shell is properly commented.Also - when I just ran on Sierra I first had to run:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Otherwise, I got the error:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
After running
sudo xcode-select -s ...
then your script worked great and accepted the license programmatically no problem. A real help...