Agreeing to the Xcode license from the command lineEdit
You may be prompted to do this by a message like:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Solution 1
This can be done by trying to run Clang from the command-line as root:
$ sudo xcrun cc
Source
Solution 2
I didn't test this one, but apparently, this also works (and is evidently more direct):
$ sudo xcodebuild -license