Unable to find a destination matching the provided destination specifier

I am attempting to test my app from the command line using fastlane but am running into issues with the build due to xcodebuild not being able to find the specified simulator. I have been attempting to debug by running the xcodebuild command manually and here is what I have been able to gather:

Running xcodebuild -scheme MyAppName -destination "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro" errors with a message saying

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, OS:18.1, name:iPhone 16 Pro }

If I run xcodebuild -scheme MyAppName -showdestinations, I can see

{ platform:iOS Simulator, id:7F3E4A35-E5DB-4EF4-AFAD-156EC463FEA8, OS:18.1, name:iPhone 16 Pro }

listed in the options. Specifying the destination using the id yields the same result.

However, if I run xcodebuild -scheme MyAppName -destination "platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro" test (note the extra test at the end) the tests run successfully.

I have checked that my minimum deployment number is correct (iOS 16), ensured that my supported platforms is set to iOS, and followed every other suggestion I could find on this matter. What am I missing here?

What version of Xcode are you using for your tools?

To find out what version of Xcode is being used by your tools, run the following command in Terminal:

xcode-select --print-path
Unable to find a destination matching the provided destination specifier
 
 
Q