xcodebuild can't find destination for testing but Xcode via UI can

I use Xcode 13.2.1 on macOS 12.3 Beta (21E5206e) and want to compile a watchOS-only application with Xcode Server.

The app runs on a simulator fine using UI of Xcode, but it fails on Xcode Server during the testing, because a destination isn't available. The server uses a command similar to this:

xcodebuild -scheme "MyApp" -destination 'id=3A6FF6DA-5EE5-41E0-83EB-573A212D9C08' test

So, I run this command in Terminal and get the following:

Command line invocation:

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -scheme "MyApp" -destination id=3A6FF6DA-5EE5-41E0-83EB-573A212D9C08 test

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ id:3A6FF6DA-5EE5-41E0-83EB-573A212D9C08 }

	The requested device could not be found because no available devices matched the request.

	Available destinations for the "MyApp" scheme:
		{ platform:iOS Simulator, id:3A6FF6DA-5EE5-41E0-83EB-573A212D9C08, OS:15.2, name:iPhone 11 }

	Ineligible destinations for the "MyApp" scheme:
		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
		{ platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }

Just to double check that I actually have the specified destination available for the project, I run:

xcodebuild -scheme "MyApp" -showdestinations

and get:

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -scheme "MyApp" -showdestinations

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }
{ platform:iOS Simulator, id:3A6FF6DA-5EE5-41E0-83EB-573A212D9C08, OS:15.2, name:iPhone 11 }

	Available destinations for the "MyApp" scheme:
		{ platform:iOS Simulator, id:3A6FF6DA-5EE5-41E0-83EB-573A212D9C08, OS:15.2, name:iPhone 11 }

	Ineligible destinations for the "MyApp" scheme:
		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
		{ platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }

Could somebody pinpoint to the problem? Why I'm getting The requested device could not be found because no available devices matched the request. if the device is actually available according to xcodebuild?

I tried:

  • to remove all simulators and create new ones
  • to remove DerivedData
  • to update target versions, I'm running iOS 15.2 and watchOS 8.3 on simulators, my application targets watchOS 8.0, so I changed it to 8.3 without any luck
  • to run using IDs and device specifiers without specific IDs of all my simulators
  • to specify in a Xcode Server bot specific simulators, or just "iOS simulators", or even my real connected device – neither worked
Post not yet marked as solved Up vote post of nokal Down vote post of nokal
1.8k views