For anyone coming across this in future, this error occurs when you haven't accepted the Xcode license on your terminal.
To do that, run:
sudo xcodebuild -license
The license agreement will be displayed, and you need to type "agree" then enter.
Do a bazel clean --expunge
, and then rebuild.