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.