{"record":{"id":"723ce72c38de23a7","repo":"dotnet/maui","slug":"no-simulator-was-found-to-run-tests-on","errorCode":null,"errorMessage":"No simulator was found to run tests on.","messagePattern":"No simulator was found to run tests on\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/ios.cake","lineNumber":443,"sourceCode":"\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new Exception(\"No device was found to run tests on.\");\n\t\t\t}\n\n\t\t\tiosVersionToRun = DEVICE_VERSION;\n\n\t\t\tInformation(\"The device to run tests: {0} {1}\", DEVICE_NAME, iosVersionToRun);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar UDID = GetUDID(testDevice, dotnetToolPath);\n\t\t\tvar sims = ListAppleSimulators();\n\n\t\t\tvar simXH = sims.Where(s => s.UDID == UDID).FirstOrDefault();\n\t\t\tif (simXH == null)\n\t\t\t{\n\t\t\t\tthrow new Exception(\"No simulator was found to run tests on.\");\n\t\t\t}\n\n\t\t\tdeviceToRun = simXH.UDID;\n\t\t\tDEVICE_NAME = simXH.Name;\n\t\t\tInformation(\"The emulator to run tests: {0} {1}\", simXH.Name, simXH.UDID);\n\t\t}\n\n\t\tInformation(\"The platform version to run tests: {0}\", iosVersionToRun);\n\t\tSetEnvironmentVariable(\"DEVICE_UDID\", deviceToRun);\n\t\tSetEnvironmentVariable(\"DEVICE_NAME\", DEVICE_NAME);\n\t\tSetEnvironmentVariable(\"PLATFORM_VERSION\", iosVersionToRun);\n        SetEnvironmentVariable(\"HEADLESS\", headless.ToString());\n\t}\n}\n\nstring GetUDID(string testDevice, string tool)\n{\n\tInformation(\"Looking for simulator: {0}\", testDevice);","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/ios.cake#L425-L461","documentation":"Thrown in InstallIpa's finally block for the simulator branch: GetUDID returned a UDID, but that UDID is not present in ListAppleSimulators() results. The simulator XHarness selected exists in its device list but is not enumerable/available for the run — typically a stale UDID, a simulator that failed to boot, or a mismatch between the XHarness device query and the simulator listing source.","triggerScenarios":"GetUDID returns a UDID from 'xharness apple device <testDevice>' but ListAppleSimulators() (often backed by Cake.AppleSimulator / simctl) does not include it; the simulator was deleted or reset between the two calls; a simulator name target whose UDID changed after a reset; simctl listing filtered out a shutting-down simulator.","commonSituations":"Simulator reset/cleanup between runs changing UDIDs; XHarness and the Cake.AppleSimulator addin reading slightly different simulator states; a simulator stuck in 'Shutdown' that XHarness lists but simctl marks unavailable; version skew between XHarness and the simulator tooling.","solutions":["Run 'xcrun simctl list' and confirm the expected UDID appears and the simulator is not in an invalid state; boot it manually if needed.","Ensure no parallel cleanup task resets simulators between GetUDID and ListAppleSimulators (disable --cleanup during debugging).","Match the simulator target name exactly to an installed runtime; a missing runtime makes XHarness return a UDID for a simulator simctl won't list.","Update the Cake.AppleSimulator addin and XHarness to compatible versions if their listings diverge."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Cross-check the UDID against the simulator listing before using it\nvar UDID = GetUDID(testDevice, dotnetToolPath);\nvar sims = ListAppleSimulators();\nif (!sims.Any(s => s.UDID == UDID))\n    throw new Exception($\"Simulator UDID {UDID} not in current listing; it may have been reset. Available: {string.Join(\", \", sims.Select(s => s.UDID))}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable simulator cleanup during debugging to avoid UDID churn between calls.","Boot the target simulator explicitly before running tests.","Keep XHarness and the Cake.AppleSimulator addin at compatible versions."],"tags":["cake","ios","simulator","xharness","udid"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}