dotnet/maui · error · Exception

No devices found

Error message

No devices found

What it means

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.

Source

Thrown at eng/devices/ios.cake:560

				{
					Information("Apple State: {0}", output);
					if (output == "Connected Devices:")
					{
						isDevice = true;
					}
					else if (isDevice)
					{
						list.Add(output);
					}
					return output;
				};
			}
	});
	Information("List count: {0}", list.Count);
	//this removes the extra lines from output
	if (list.Count == 0)
	{
		throw new Exception($"No devices found");
		return;
	}
	list.Remove(list.Last());
	list.Remove(list.Last());
	foreach (var item in list)
	{
		var stringToTest = $"Device: {item.Trim()}";
		Information(stringToTest);
		var regex = new System.Text.RegularExpressions.Regex(@"Device:\s+((?:[^\s]+(?:\s+[^\s]+)*)?)\s+([0-9A-Fa-f-]+)\s+([\d.]+)\s+(iPhone|iPad)\s+iOS");
		var match = regex.Match(stringToTest);
		if (match.Success)
		{
			deviceName = match.Groups[1].Value;
			deviceUdid = match.Groups[2].Value;
			deviceVersion = match.Groups[3].Value;
			deviceOS = match.Groups[4].Value;
			Information("DeviceName:{0} udid:{1} version:{2} os:{3}", deviceName, deviceUdid, deviceVersion, deviceOS);
			if (version.Contains(deviceVersion.Split(".")[0]))

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Physically connect and unlock an iOS device, then accept the Trust This Computer prompt.
  2. Run 'xcrun devicectl list devices' or 'xharness apple state' manually to confirm the device is visible before invoking the build.
  3. If no device is available, switch the target to a simulator so GetDevices is not called.
  4. Re-pair the device: unplug, replug, and trust; or reset location/privacy settings on the device.
Defensive patterns

Strategy: validation

Validate before calling

// Before GetDevices, confirm a physical device is visible
var stateOutput = StartProcess("xharness", new ProcessSettings { Arguments = "apple state", RedirectStandardOutput = true });
// (parse output) — if no 'Connected Devices' entries, fail with a clear message

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/71c7364e4165c287. Report an issue: GitHub.