diff --git a/packages/cli-platform-ios/src/commands/logIOS/index.ts b/packages/cli-platform-ios/src/commands/logIOS/index.ts index 42970815a..9ca5f31f2 100644 --- a/packages/cli-platform-ios/src/commands/logIOS/index.ts +++ b/packages/cli-platform-ios/src/commands/logIOS/index.ts @@ -36,6 +36,11 @@ async function logIOS(_argv: Array, _ctx: Config, args: Args) { ({type, isAvailable}) => type === 'simulator' && isAvailable, ); + if (availableSimulators.length === 0) { + logger.error('No simulators detected. Install simulators via Xcode.'); + return; + } + const bootedAndAvailableSimulators = bootedSimulators.map((booted) => { const available = availableSimulators.find( ({udid}) => udid === booted.udid, @@ -44,7 +49,7 @@ async function logIOS(_argv: Array, _ctx: Config, args: Args) { }); if (bootedAndAvailableSimulators.length === 0) { - logger.error('No active iOS device found'); + logger.error('No booted and available iOS simulators found.'); return; } diff --git a/packages/cli-platform-ios/src/commands/runIOS/index.ts b/packages/cli-platform-ios/src/commands/runIOS/index.ts index f57077367..d9c9065df 100644 --- a/packages/cli-platform-ios/src/commands/runIOS/index.ts +++ b/packages/cli-platform-ios/src/commands/runIOS/index.ts @@ -100,7 +100,18 @@ async function runIOS(_: Array, ctx: Config, args: FlagsT) { const {mode, scheme} = await getConfiguration(xcodeProject, sourceDir, args); - const availableDevices = await listIOSDevices(); + const devices = await listIOSDevices(); + + const availableDevices = devices.filter( + ({isAvailable}) => isAvailable === true, + ); + + if (availableDevices.length === 0) { + return logger.error( + 'iOS devices or simulators not detected. Install simulators via Xcode or connect a physical iOS device', + ); + } + if (args.listDevices || args.interactive) { if (args.device || args.udid) { logger.warn( @@ -126,7 +137,7 @@ async function runIOS(_: Array, ctx: Config, args: FlagsT) { if (!args.device && !args.udid && !args.simulator) { const bootedDevices = availableDevices.filter( - ({type, isAvailable}) => type === 'device' && isAvailable, + ({type}) => type === 'device', ); const simulators = getSimulators();