{"record":{"id":"71c7364e4165c287","repo":"dotnet/maui","slug":"no-devices-found","errorCode":null,"errorMessage":"No devices found","messagePattern":"No devices found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/ios.cake","lineNumber":560,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tInformation(\"Apple State: {0}\", output);\n\t\t\t\t\tif (output == \"Connected Devices:\")\n\t\t\t\t\t{\n\t\t\t\t\t\tisDevice = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (isDevice)\n\t\t\t\t\t{\n\t\t\t\t\t\tlist.Add(output);\n\t\t\t\t\t}\n\t\t\t\t\treturn output;\n\t\t\t\t};\n\t\t\t}\n\t});\n\tInformation(\"List count: {0}\", list.Count);\n\t//this removes the extra lines from output\n\tif (list.Count == 0)\n\t{\n\t\tthrow new Exception($\"No devices found\");\n\t\treturn;\n\t}\n\tlist.Remove(list.Last());\n\tlist.Remove(list.Last());\n\tforeach (var item in list)\n\t{\n\t\tvar stringToTest = $\"Device: {item.Trim()}\";\n\t\tInformation(stringToTest);\n\t\tvar regex = new System.Text.RegularExpressions.Regex(@\"Device:\\s+((?:[^\\s]+(?:\\s+[^\\s]+)*)?)\\s+([0-9A-Fa-f-]+)\\s+([\\d.]+)\\s+(iPhone|iPad)\\s+iOS\");\n\t\tvar match = regex.Match(stringToTest);\n\t\tif (match.Success)\n\t\t{\n\t\t\tdeviceName = match.Groups[1].Value;\n\t\t\tdeviceUdid = match.Groups[2].Value;\n\t\t\tdeviceVersion = match.Groups[3].Value;\n\t\t\tdeviceOS = match.Groups[4].Value;\n\t\t\tInformation(\"DeviceName:{0} udid:{1} version:{2} os:{3}\", deviceName, deviceUdid, deviceVersion, deviceOS);\n\t\t\tif (version.Contains(deviceVersion.Split(\".\")[0]))","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/ios.cake#L542-L578","documentation":"Thrown in GetDevices after parsing 'xharness apple state' output: the 'Connected Devices:' header was seen (isDevice=true) but zero device lines were collected. This means XHarness detected the connected-devices section but listed no physical devices, so list.Count is 0. The unreachable 'return' after the throw is dead code.","triggerScenarios":"Running GetDevices (physical-device selection) on a Mac with no USB-attached iOS device; the device is connected but not trusted/paired so XHarness omits it; XHarness version that prints the header even when empty; device connected but in an invalid state (recovery mode).","commonSituations":"CI runner with no device attached but the job targeting a device; developer machine where the device prompt to Trust was dismissed; a device that disconnected after xharness started but before listing; lockdown pairing failure.","solutions":["Physically connect and unlock an iOS device, then accept the Trust This Computer prompt.","Run 'xcrun devicectl list devices' or 'xharness apple state' manually to confirm the device is visible before invoking the build.","If no device is available, switch the target to a simulator so GetDevices is not called.","Re-pair the device: unplug, replug, and trust; or reset location/privacy settings on the device."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before GetDevices, confirm a physical device is visible\nvar stateOutput = StartProcess(\"xharness\", new ProcessSettings { Arguments = \"apple state\", RedirectStandardOutput = true });\n// (parse output) — if no 'Connected Devices' entries, fail with a clear message","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the device is connected, unlocked, and trusted before running device-target jobs.","Do not target a physical device in CI runners without a device attached.","Prefer simulator targets when no device is available."],"tags":["cake","ios","physical-device","xharness","usb"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}