accepting Xcode license without having whole Xcode
Running xcodebuild requires you to have the whole Xcode (GUI) package installed.

Instead run this command:

 sudo xcrun cc


It will allow you to accept the license from the CLI.