dotnet/maui · error · Exception
No device was found to install the app on. See the Setup met
Error message
No device was found to install the app on. See the Setup method for more details.
What it means
Thrown in the ArgumentCustomization of RunMacAndiOSTests when the target device string contains 'device' (a physical iOS device target like 'ios-device') but the global DEVICE_UDID was never populated. DEVICE_UDID is set by connectToDevice/GetDevices; an empty value means device selection did not run or found nothing.
Source
Thrown at eng/devices/ios.cake:203
ToolPath = toolPath,
DiagnosticOutput = true,
ArgumentCustomization = args =>
{
args.Append("run xharness apple test " +
$"--app=\"{testApp}\" " +
$"--targets=\"{device}\" " +
$"--output-directory=\"{resultsDir}\" " +
$"--timeout=01:15:00 " +
$"--launch-timeout={launchTimeout} " +
xcode_args +
$"--verbosity=\"Debug\" " +
$"--set-env=\"TestFilter={category}\" ");
if (device.Contains("device"))
{
if (string.IsNullOrEmpty(DEVICE_UDID))
{
throw new Exception("No device was found to install the app on. See the Setup method for more details.");
}
args.Append($"--device=\"{DEVICE_UDID}\" ");
}
return args;
}
};
});
}
void ExecutePrepareUITests(string project, string app, string device, string resultsDir, string binDir, string config, string tfm, string rid, string ver, string toolPath, bool headless)
{
Information("Preparing UI Tests...");
Information($"Testing Device: {device}");
Information($"Testing App Project: {app}");
Information($"USE_NATIVE_AOT: {USE_NATIVE_AOT}");
var testApp = GetTestApplications(app, device, config, tfm, rid).FirstOrDefault();
View on GitHub (pinned to f377ff1c5e)
Solutions
- Ensure the connectToDevice/Setup task runs before the test task so GetDevices populates DEVICE_UDID.
- Confirm a physical device is connected and trusted: run 'dotnet run xharness apple state' and check the Connected Devices section.
- If you meant a simulator, switch --device to a simulator target (e.g. ios-simulator-64) so the device.Contains('device') branch is not taken.
- Pass --udid explicitly or set IOS_SIMULATOR_UDID/DEVICE_UDID if the selection step cannot auto-detect.
Example fix
// before — throws late, inside argument building
if (device.Contains("device"))
{
if (string.IsNullOrEmpty(DEVICE_UDID))
throw new Exception("No device was found to install the app on. See the Setup method for more details.");
args.Append($"--device=\"{DEVICE_UDID}\" ");
}
// after — validate up front with the resolved value in the message
if (device.Contains("device"))
{
if (string.IsNullOrEmpty(DEVICE_UDID))
throw new Exception($"Physical device target '{device}' selected but DEVICE_UDID is empty. " +
"Run connectToDevice first or pass --udid.");
args.Append($"--device=\"{DEVICE_UDID}\" ");
} Defensive patterns
Strategy: validation
Validate before calling
// Validate device target selection before building xharness args
if (device.Contains("device") && string.IsNullOrEmpty(DEVICE_UDID))
throw new Exception($"Physical device target '{device}' needs DEVICE_UDID; run connectToDevice or pass --udid."); Prevention
- Make connectToDevice a hard dependency of the test task for device targets.
- Echo DEVICE_UDID in Setup logs so an empty value is visible before tests start.
- Avoid target names containing the substring 'device' for simulator runs.
When it happens
Trigger: Passing --device=ios-device (or any target containing 'device') without first running the connectToDevice task; running connectToDevice against a simulator target so DEVICE_UDID stays empty, then switching to a device target; a physical device disconnected between selection and test execution.
Common situations: CI job specifying a physical-device target but the runner has no device attached; local run skipping the Setup/connect step; the device falling off USB mid-run; using a target name that accidentally contains the substring 'device' for a simulator.
Related errors
- No device was found to run tests on.
- No simulator was found to run tests on.
- No devices found
- No devices found for version {version}
- No test results found.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/3a623632e9c9216d.
Report an issue: GitHub.