{"record":{"id":"0dc65ccbcf6ca358","repo":"dotnet/maui","slug":"no-devices-found-for-version-version","errorCode":null,"errorMessage":"No devices found for version {version}","messagePattern":"No devices found for version (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/ios.cake","lineNumber":595,"sourceCode":"\t\t\tInformation(\"DeviceName:{0} udid:{1} version:{2} os:{3}\", deviceName, deviceUdid, deviceVersion, deviceOS);\n\t\t\tif (version.Contains(deviceVersion.Split(\".\")[0]))\n\t\t\t{\n\t\t\t\tInformation(\"We want this device: {0} {1} because it matches {2}\", deviceName, deviceVersion, version);\n\t\t\t\tDEVICE_UDID = deviceUdid;\n\t\t\t\tDEVICE_VERSION = deviceVersion;\n\t\t\t\tDEVICE_NAME = deviceName;\n\t\t\t\tDEVICE_OS = deviceOS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tInformation(\"No match found for {0}\", stringToTest);\n\t\t}\n\t}\n\tif (string.IsNullOrEmpty(DEVICE_UDID))\n\t{\n\t\tthrow new Exception($\"No devices found for version {version}\");\n\t}\n}\n","sourceCodeStart":577,"sourceCodeEnd":598,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/ios.cake#L577-L598","documentation":"Thrown in GetDevices when devices were enumerated (list non-empty) but none matched the requested iOS major version. The loop parses each device line with a regex capturing name/UDID/version/OS, and only sets DEVICE_UDID when version.Contains(deviceVersion major). If no device's major version matches the requested version, DEVICE_UDID stays empty.","triggerScenarios":"Requesting tests on iOS 18 (--apiversion=18 or DefaultVersion) when the connected device runs iOS 17 or 16; a device present but the regex not matching its line format (so it's skipped as 'No match found'); multiple devices connected, none on the right version.","commonSituations":"DefaultVersion updated in the repo but the lab devices not yet upgraded; developer's personal device on a different iOS; XHarness output format change breaking the regex so device lines parse as non-matches; requesting a version substring that matches no device's major version.","solutions":["Check the 'Device:' Information lines and the 'No match found' warnings to see what versions were actually seen, then connect a device on the requested major version.","Pass --apiversion matching a connected device's major version (e.g. --apiversion=17 for an iOS 17 device).","If lines show as 'No match found', the regex at line 569 may not match the current XHarness output format — update it or capture the raw line for debugging.","Run on a simulator instead if no physical device matches the required version."],"exampleFix":"// before: major-version-only match, easy to miss the right device\nif (version.Contains(deviceVersion.Split(\".\")[0]))\n\n// after: log candidates and compare explicitly\nvar deviceMajor = deviceVersion.Split(\".\")[0];\nInformation($\"Candidate {deviceName} iOS {deviceVersion} (major {deviceMajor}) vs requested {version}\");\nif (version == deviceMajor || version.StartsWith(deviceMajor + \".\"))","handlingStrategy":"validation","validationCode":"// Before GetDevices, list available device versions and compare to the request\n// run 'xharness apple state', parse versions, then:\nif (!availableVersions.Any(v => v.StartsWith(requestedVersion)))\n    throw new Exception($\"No connected device on iOS {requestedVersion}; available: {string.Join(\", \", availableVersions)}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep DefaultVersion in sync with the lab devices' actual iOS versions.","Log every parsed device line and the requested version so mismatches are obvious.","Update the device-line regex when XHarness output format changes."],"tags":["cake","ios","physical-device","version-mismatch","xharness"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}