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

I'm facing this issue intermittently since using Xcode 16 beta 4 on macOS 14.5 when starting xcodebuild build with -destination option.

20:56:07 ▸ xcodebuild: error: Unable to find a device matching the provided destination specifier:
20:56:07 ▸ { platform:iOS Simulator, OS:15.4, name:iPhone 13 Pro }
20:56:07 ▸ The requested device could not be found because multiple devices matched the request. (
20:56:07 ▸ "<DVTiPhoneSimulator: 0x151fb1fe0> {\n\t\tSimDevice: iPhone 13 Pro (CB36E92A-C32D-481C-A407-28123ABEBF66, iOS 15.4, Shutdown)\n}",
20:56:07 ▸ "<DVTiPhoneSimulator: 0x151fb4070> {\n\t\tSimDevice: iPhone 13 Pro (0EBBCB9A-5FBA-4998-903B-1415315D1533, iOS 15.4, Shutdown)\n}"
20:56:07 ▸ )

This mac is mac mini 2023 M2 Pro 32GB memory, running with multiple simruntimes installed:

$ sudo xcrun simctl runtime list
Password:
== Disk Images ==
-- iOS --
iOS 17.5 (21F79) - 9FC1CFB3-33A4-4F31-AF40-BAB448F6FA0D (Ready)
iOS 16.4 (20E247) - 3BFB66B1-075B-4B17-951C-B691BAC41C73 (Ready)
iOS 17.2 (21C62) - C8D4111F-1F7A-4FC2-AC6A-BF68A47EEDCE (Ready)
iOS 17.4 (21E213) - 0B8ECC25-EF76-4744-9D77-8256A57D1605 (Ready)
iOS 18.0 (22A5326g) - 7217B9B2-A113-4B6B-915E-CAB70431B415 (Ready)
iOS 17.0.1 (21A342) - C4FE430B-DD3F-4108-B2E7-B13A04989863 (Ready)
iOS 15.4 (19E240) - CAB77B36-B6D3-4F5D-8956-E7A3105AC910 (Ready)
iOS 18.1 (22B5023e) - 9E53F2C6-BA91-421C-848F-F78043179361 (Ready)
-- tvOS --
tvOS 17.2 (21K364) - 8A9929AE-0521-498D-884A-F87BD16612CD (Ready)
tvOS 16.4 (20L494) - 3354C9A4-E177-4030-98F2-0735970E1607 (Ready)
tvOS 17.4 (21L224) - 724CD6DA-EAC2-4076-A578-C84872A36E5E (Ready)
tvOS 15.2 (19K50) - 0AE51520-B1E2-4ED9-80A4-717291FC5E96 (Ready)
tvOS 18.0 (22J5335e) - E839E471-AA01-46E1-A4AD-DF4B98B46525 (Ready)
tvOS 17.5 (21L569) - C432547A-F7EF-4B34-AD43-D3E839CB49E1 (Ready)
tvOS 17.0 (21J353) - 6A08D50B-D9BF-4496-A5C5-FE21373B11DD (Ready)
tvOS 18.0 (22J5324f) - B2C7CA72-AAE6-4DF9-A4B0-26A0EB9462F7 (Ready)
-- watchOS --
watchOS 11.0 (22R5318h) - 56250DF3-CF78-4C5D-B502-0B53DE16ABEB (Ready)
watchOS 10.4 (21T214) - CC71D3D3-EA19-4F0B-BF3E-388D686AB300 (Ready)
watchOS 10.0 (21R355) - 3623992D-88CF-41CB-8091-AF1F8CE16717 (Ready)
watchOS 10.2 (21S364) - C0666241-AA31-4CF7-98B9-EA5394331DC6 (Ready)
watchOS 9.4 (20T253) - EED82B11-589D-41AF-B290-844F59AECECB (Ready)
watchOS 10.5 (21T575) - 0D749B4E-DC69-4F27-8982-510AB985B822 (Ready)
watchOS 8.3 (19S51) - 8123ABC7-5465-4467-A5DA-CE9C50E1081D (Ready)
watchOS 11.0 (22R5328f) - 648646A0-A370-48A4-881B-15B2422DE698 (Ready)
-- xrOS --
xrOS 2.0 (22N5297g) - C2C8E4EE-3738-4706-823E-2B4138CE90BE (Ready)
xrOS 1.0 (21N305) - 29EAB8D4-160D-4A3B-AB7C-7325D205AC4C (Ready)
xrOS 2.0 (22N5286g) - 1F92EE9A-A5F9-45F7-8075-7FD7BC4EF81E (Ready)
xrOS 1.1 (21O209) - DB15F0B2-C9E4-424D-9A50-8D6EDB131142 (Ready)
xrOS 1.2 (21O5565d) - 83A26410-A8A8-41F6-A5A1-E0A7E24B8BA0 (Ready)

I've never seen this kind of simulator missing error.

Nor installing any duplicate runtime(s) on the same machine because it will show error message like 'unable to use this runtime' on xcrun simctl runtime list.

Could anyone give me a tip of avoiding this kind of error?

== Devices ==
-- iOS 15.4 --
    iPhone 13 Pro (F86F0DD7-8C70-48FE-BA9F-02CFCB5FE417) (Shutdown)
    iPhone 13 Pro Max (DD28B2D3-675C-4FAD-A5DD-F4A4BE45DAD0) (Shutdown)
    iPhone 13 mini (C1CCCE8D-7424-4FA2-B1F2-FBF9DBD1CA64) (Shutdown)
    iPhone 13 (B251760E-E6C0-4945-AEFD-365B10F74A68) (Shutdown)
    iPhone SE (3rd generation) (CCA0A16C-060F-44CF-8716-009026D0701C) (Shutdown)
    iPod touch (7th generation) (094749BD-20AA-4DFD-9762-9F38A32D1209) (Shutdown)
    iPad Pro (9.7-inch) (594577D4-B27F-401B-9ACF-9FD256B42D6F) (Shutdown)
    iPad (9th generation) (B9631ABA-A4B5-4526-B351-CE06C02A43A8) (Shutdown)
    iPad Pro (11-inch) (3rd generation) (4F5BA965-C4B1-4934-B134-04A7649D7BF4) (Shutdown)
    iPad Pro (12.9-inch) (5th generation) (35CA6F06-4194-4801-89B3-0DEF6C0A1F98) (Shutdown)
    iPad Air (5th generation) (52982B96-5E14-426A-96C0-0F90FC163EF8) (Shutdown)
    iPad mini (6th generation) (E7B3EE06-D2B2-45F2-8C4C-B0A5CCDEF771) (Shutdown)

Adding information from xcrun simctl list on the same machine and this would show clearly that no duplications are seen.

You have two phones named "iPhone 13 Pro" configured for iOS 15.4.

The important output to look at is simctl list devices.

Based on the output, I'm guessing you ran sudo simctl list devices for your followup comment as the UDIDs do not match the original post.

You should almost never use sudo with xcrun simctl as it probably isn't doing what you want it to ;)

Here's the fail log of xcodebuild with -destination flag, and without sudo upfront:

15:39:45 Exit status of command 'set -o pipefail && xcodebuild -project "SampleApp.xcodeproj" -scheme "SampleApp" -configuration "Release" clean -destination "platform=iOS Simulator,name=iPhone 13 Pro,OS=15.4" -derivedDataPath "/path/to/.derived_data/sim_app" build | tee '/path/to/artifacts/logs/build_sim/xcodebuild.log' | xcpretty --color --simple' was 70 instead of 0.

15:39:45 2024-09-25 15:39:14.700 xcodebuild[91142:22610080] Malformed bundle does not contain an identifier at /Library/Developer/CoreSimulator/Volumes/tvOS_22J5335e/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS 18.0.simruntime

15:39:45 2024-09-25 15:39:14.760 xcodebuild[91142:22610212] Malformed bundle does not contain an identifier at /Library/Developer/CoreSimulator/Volumes/tvOS_22J5335e/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS 18.0.simruntime

15:39:45 2024-09-25 15:39:43.986 xcodebuild[91142:22610077] Writing error result bundle to /var/folders/t2/vppt8b613w1b1pwfycwzgnc00000gr/T/ResultBundle_2024-25-09_15-39-0043.xcresult

15:39:45 xcodebuild: error: Unable to find a device matching the provided destination specifier:

15:39:45 		{ platform:iOS Simulator, OS:15.4, name:iPhone 13 Pro }

15:39:45 

15:39:45 	The requested device could not be found because multiple devices matched the request. (

15:39:45     "<DVTiPhoneSimulator: 0x12467d3e0> {\n\t\tSimDevice: iPhone 13 Pro (7C44F49C-1406-4675-8297-0BB1E32030A4, iOS 15.4, Shutdown)\n}",

15:39:45     "<DVTiPhoneSimulator: 0x1246788e0> {\n\t\tSimDevice: iPhone 13 Pro (723AB83F-84B2-4553-A7FB-FE97FBC72A12, iOS 15.4, Shutdown)\n}"

15:39:45 )

...

15:39:45 	Available destinations for the "SampleApp" scheme:

15:39:45 		{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00006020-0014092C3498C01E, name:My Mac }

15:39:45 		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }

15:39:45 		{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }

15:39:45 		{ platform:visionOS Simulator, variant:Designed for [iPad,iPhone], id:5E4672C1-BFDC-4BF8-AECC-9101CAF005E2, OS:2.0, name:Apple Vision Pro }

15:39:45 		{ platform:visionOS Simulator, variant:Designed for [iPad,iPhone], id:F828FD1C-C6A9-4671-8A30-45888FE542C2, OS:2.1, name:Apple Vision Pro }

15:39:45 		{ platform:iOS Simulator, id:27B137B4-DDF5-4091-A77B-AEAE819E60BE, OS:15.4, name:iPad (9th generation) }

15:39:45 		{ platform:iOS Simulator, id:27B137B4-DDF5-4091-A77B-AEAE819E60BE, OS:15.4, name:iPad (9th generation) }

15:39:45 		{ platform:iOS Simulator, id:84E80242-3066-45BB-BE4A-24EC1512BE0E, OS:15.4, name:iPad (9th generation) }

15:39:45 		{ platform:iOS Simulator, id:84E80242-3066-45BB-BE4A-24EC1512BE0E, OS:15.4, name:iPad (9th generation) }



...



15:39:45 		{ platform:iOS Simulator, id:723AB83F-84B2-4553-A7FB-FE97FBC72A12, OS:15.4, name:iPhone 13 Pro }

15:39:45 		{ platform:iOS Simulator, id:723AB83F-84B2-4553-A7FB-FE97FBC72A12, OS:15.4, name:iPhone 13 Pro }

15:39:45 		{ platform:iOS Simulator, id:7C44F49C-1406-4675-8297-0BB1E32030A4, OS:15.4, name:iPhone 13 Pro }

15:39:45 		{ platform:iOS Simulator, id:7C44F49C-1406-4675-8297-0BB1E32030A4, OS:15.4, name:iPhone 13 Pro }

15:39:45 		{ platform:iOS Simulator, id:AA3C6F9C-A503-4301-8C70-760D20F31103, OS:15.4, name:iPhone 13 Pro Max }

15:39:45 		{ platform:iOS Simulator, id:AA3C6F9C-A503-4301-8C70-760D20F31103, OS:15.4, name:iPhone 13 Pro Max }
...

Why do the simulator devices show up doubled? I executed job only once but seems like CoreSimulator starts up twice. I know this occurs intermittently but the problem shows up too frequently.

The requested device could not be found because multiple devices matched the request.
 
 
Q