Failed to build WebDriverAgent

I have issued a command in Terminal:

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=’ test

*: Provided my device UDID.

It is showing: xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance

Device: iPhone 6, iOS: 11.4.1

How to resolve the issue?

You can try switching your xcode’s tools directory:

sudo xcode-select -s /Applications/

Assuming your Xcode directory is at /Applications/

Hope this helps,