Skip to content

Commit

Permalink
fix: check if there are any available simulators / physical devices (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak authored Oct 31, 2023
1 parent 5fcce56 commit 4d149bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/cli-platform-ios/src/commands/logIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ async function logIOS(_argv: Array<string>, _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,
Expand All @@ -43,7 +48,7 @@ async function logIOS(_argv: Array<string>, _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;
}

Expand Down
15 changes: 13 additions & 2 deletions packages/cli-platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,18 @@ async function runIOS(_: Array<string>, 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(
Expand All @@ -121,7 +132,7 @@ async function runIOS(_: Array<string>, 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();
Expand Down

0 comments on commit 4d149bc

Please sign in to comment.