I have a similar issue building an installer plugin which has as Swift package included (don't ask me why). I got different but similar build error messages initially. I installed the additional tools required by Xcode and also updated the command line tools xcode-select --install. After all the updates my latest error is:
Cleaning Installer Plugin...
xcodebuild: error: Could not resolve package dependencies:
Internal error: missingPackageDescriptionModule
Build failed at "all" action with error:
Fail: ./installer-plugin/build.sh returned code 74
Aborted.
That's my build command:
local symroot="$(xcodebuild -showBuildSettings -project "${XCB_PROJECT}" -scheme "${XCB_SCHEME}" | grep SYMROOT | sed -n 2p | sed -e 's#.*=\(\)#\1#' | sed 's/^ *//g')"