{"record":{"id":"3a623632e9c9216d","repo":"dotnet/maui","slug":"no-device-was-found-to-install-the-app-on-see-the","errorCode":null,"errorMessage":"No device was found to install the app on. See the Setup method for more details.","messagePattern":"No device was found to install the app on\\. See the Setup method for more details\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/ios.cake","lineNumber":203,"sourceCode":"\t\t\tToolPath = toolPath,\n\t\t\tDiagnosticOutput = true,\n\t\t\tArgumentCustomization = args =>\n\t\t\t{\n\t\t\t\targs.Append(\"run xharness apple test \" +\n\t\t\t\t\t$\"--app=\\\"{testApp}\\\" \" +\n\t\t\t\t\t$\"--targets=\\\"{device}\\\" \" +\n\t\t\t\t\t$\"--output-directory=\\\"{resultsDir}\\\" \" +\n\t\t\t\t\t$\"--timeout=01:15:00 \" +\n\t\t\t\t\t$\"--launch-timeout={launchTimeout} \" +\n\t\t\t\t\txcode_args +\n\t\t\t\t\t$\"--verbosity=\\\"Debug\\\" \" +\n\t\t\t\t\t$\"--set-env=\\\"TestFilter={category}\\\" \");\n\n\t\t\t\tif (device.Contains(\"device\"))\n\t\t\t\t{\n\t\t\t\t\tif (string.IsNullOrEmpty(DEVICE_UDID))\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new Exception(\"No device was found to install the app on. See the Setup method for more details.\");\n\t\t\t\t\t}\n\t\t\t\t\targs.Append($\"--device=\\\"{DEVICE_UDID}\\\" \");\n\t\t\t\t}\n\t\t\t\treturn args;\n\t\t\t}\n\t\t};\n\t});\n}\n\nvoid ExecutePrepareUITests(string project, string app, string device, string resultsDir, string binDir, string config, string tfm, string rid, string ver, string toolPath, bool headless)\n{\n\tInformation(\"Preparing UI Tests...\");\n\tInformation($\"Testing Device: {device}\");\n\tInformation($\"Testing App Project: {app}\");\n\tInformation($\"USE_NATIVE_AOT: {USE_NATIVE_AOT}\");\n\t\n\tvar testApp = GetTestApplications(app, device, config, tfm, rid).FirstOrDefault();\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/ios.cake#L185-L221","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — throws late, inside argument building\nif (device.Contains(\"device\"))\n{\n    if (string.IsNullOrEmpty(DEVICE_UDID))\n        throw new Exception(\"No device was found to install the app on. See the Setup method for more details.\");\n    args.Append($\"--device=\\\"{DEVICE_UDID}\\\" \");\n}\n\n// after — validate up front with the resolved value in the message\nif (device.Contains(\"device\"))\n{\n    if (string.IsNullOrEmpty(DEVICE_UDID))\n        throw new Exception($\"Physical device target '{device}' selected but DEVICE_UDID is empty. \" +\n            \"Run connectToDevice first or pass --udid.\");\n    args.Append($\"--device=\\\"{DEVICE_UDID}\\\" \");\n}","handlingStrategy":"validation","validationCode":"// Validate device target selection before building xharness args\nif (device.Contains(\"device\") && string.IsNullOrEmpty(DEVICE_UDID))\n    throw new Exception($\"Physical device target '{device}' needs DEVICE_UDID; run connectToDevice or pass --udid.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cake","ios","xharness","physical-device","udid"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}