{"record":{"id":"cc2e9a346c7c9715","repo":"moeru-ai/airi","slug":"no-platform-devices-or-simulators-found-connec","errorCode":null,"errorMessage":"No ${platform} devices or simulators found. Connect a device, start a simulator or emulator, or pass --target explicitly.","messagePattern":"No (.+?) devices or simulators found\\. Connect a device, start a simulator or emulator, or pass --target explicitly\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cap-vite/src/native.ts","lineNumber":155,"sourceCode":"  let target: string | undefined\n  if (platform === 'ios') {\n    target = env.CAPACITOR_DEVICE_ID_IOS\n  }\n  else if (platform === 'android') {\n    target = env.CAPACITOR_DEVICE_ID_ANDROID\n  }\n\n  if (!target) {\n    if (!platform) {\n      return capArgs\n    }\n\n    const targets = await listTargets(platform)\n    target = targets.find(device => device.id)?.id\n  }\n\n  if (!target) {\n    throw new Error(`No ${platform} devices or simulators found. Connect a device, start a simulator or emulator, or pass --target explicitly.`)\n  }\n\n  return [platformArg, '--target', target, ...rest]\n}\n\nexport function pickServerUrl(server: Pick<ViteDevServer, 'resolvedUrls'>): URL {\n  const url = server.resolvedUrls?.network?.[0] ?? server.resolvedUrls?.local?.[0]\n\n  if (!url) {\n    throw new Error('Vite did not expose a reachable dev server URL.')\n  }\n\n  return new URL(url)\n}\n\nexport function shouldRestartForNativeChange(file: string, platform: CapacitorPlatform, cwd: string): boolean {\n  const absoluteFile = resolve(cwd, file)\n  const platformRoot = resolve(cwd, platform)","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/cap-vite/src/native.ts#L137-L173","documentation":"Thrown by resolveCapRunArgs() when no explicit --target was supplied, no device id is in CAPACITOR_DEVICE_ID_IOS/ANDROID, and listTargets(platform) returned an empty or id-less list. It is the final fallback before cap-vite injects a --target value for the Capacitor run.","triggerScenarios":"Calling runCapVite or capVitePlugin on a machine with no connected device, no running iOS Simulator, and no running Android emulator; listTargets returns [] because no target has a string id.","commonSituations":"First run on a fresh dev machine with no simulator booted; CI without a booted emulator; the platform tooling (Xcode simulators / AVD) is installed but nothing is launched; USB device not trusted/paired.","solutions":["Start an iOS Simulator (open -a Simulator) or an Android emulator (emulator -avd <name>) and retry.","Connect and trust a physical device over USB/Wi-Fi debugging.","Pass an explicit target: runCapVite(viteArgs, ['ios', '--target', '<id>']).","Set CAPACITOR_DEVICE_ID_IOS or CAPACITOR_DEVICE_ID_ANDROID to a known device id to skip discovery."],"exampleFix":"// before\nawait runCapVite(viteArgs, ['ios'])\n// after\nawait runCapVite(viteArgs, ['ios', '--target', '00008110-XXXX'])","handlingStrategy":"try-catch","validationCode":"// Check device availability before relying on auto-discovery\nimport { x } from 'tinyexec'\n\nasync function hasAnyTarget(platform: 'ios' | 'android'): Promise<boolean> {\n  try {\n    const out = await x('cap', ['run', platform, '--list', '--json'])\n    const list = JSON.parse(out.stdout) as { id?: string }[]\n    return list.some(t => typeof t.id === 'string')\n  } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runCapVite(viteArgs, ['ios'])\n} catch (error) {\n  if (error instanceof Error && /No .* devices or simulators found/.test(error.message)) {\n    console.error('Start an iOS Simulator or pass --target <id>.')\n    process.exit(1)\n  }\n  throw error\n}","preventionTips":["Boot a simulator/emulator before invoking cap-vite.","Set CAPACITOR_DEVICE_ID_IOS/ANDROID in a .env for your dev machine.","In CI, launch the emulator as a setup step and wait for boot."],"tags":["capacitor","device-discovery","simulator","emulator"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}