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

suddenly i got the same problem

Same problem , any solutions?

Facing the same issue....anyone resolved it?

have you resolved this? please help

I was having the same issue and noticed that my minimum deployment in xcode was 15.5, and I was trying to load simulators with an IOS version that was below the minimum. be sure to take a look.

We had a similar issue after updating Xcode to version 15.3 where the command:

xcodebuild -scheme AppScheme -destination 'platform=iOS Simulator,id=3ECD61FB-8C8C-44AB-9D9D-27FD1386D261' build test

failed with the following error:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, id:3ECD61FB-8C8C-44AB-9D9D-27FD1386D261 }

Ineligible destinations for the "AppScheme" scheme:
[15:40:38]: ▸ 		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 17.4 is not installed. To use with Xcode, first download and install the platform }

Our destination was a 17.0.1 simulator which was installed and also listed for xcrun simctl list devices. It turned out that xcodebuild was not able to find any destinations when running:

xcodebuild -scheme "MyScheme" -showdestinations

Our solution was to ensure that the LATEST Simulator version installed for the Xcode Version, which in this case was iOS 17.4.

Maybe this helps others as well ✌️

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