Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ export type AVDExceptionCode = typeof ERR_UNSUITABLE_API_INSTALLATION;
export class AVDException extends AndroidException<AVDExceptionCode> {}

export type EmulatorExceptionCode =
| typeof ERR_ALREADY_RUNNING
| typeof ERR_AVD_HOME_NOT_FOUND
| typeof ERR_NON_ZERO_EXIT
| typeof ERR_UNKNOWN_AVD;
typeof ERR_ALREADY_RUNNING | typeof ERR_AVD_HOME_NOT_FOUND | typeof ERR_NON_ZERO_EXIT | typeof ERR_UNKNOWN_AVD;

export class EmulatorException extends AndroidException<EmulatorExceptionCode> {}

Expand All @@ -98,10 +95,7 @@ export type SDKExceptionCode =
export class SDKException extends AndroidException<SDKExceptionCode> {}

export type IOSRunExceptionCode =
| typeof ERR_TARGET_NOT_FOUND
| typeof ERR_NO_DEVICE
| typeof ERR_NO_TARGET
| typeof ERR_DEVICE_LOCKED;
typeof ERR_TARGET_NOT_FOUND | typeof ERR_NO_DEVICE | typeof ERR_NO_TARGET | typeof ERR_DEVICE_LOCKED;

export class IOSRunException extends Exception<IOSRunExceptionCode> {}

Expand Down
22 changes: 17 additions & 5 deletions src/ios/utils/simulator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathExists } from '@ionic/utils-fs';
import { spawnSync } from 'child_process'; // TODO: need cross-spawn for windows?
import * as Debug from 'debug';

Expand Down Expand Up @@ -85,11 +86,22 @@ export async function runOnSimulator(udid: string, appPath: string, bundleId: st

const xCodePath = await getXCodePath();
debug(`Running simulator ${udid}`);
const openResult = spawnSync(
'open',
[`${xCodePath}/Applications/Simulator.app`, '--args', '-CurrentDeviceUDID', udid],
{ encoding: 'utf8' },
);

const simulatorApp = `${xCodePath}/Applications/Simulator.app`;
const deviceHubApp = `${xCodePath}/../Applications/DeviceHub.app`;

let openArgs: string[];

if (await pathExists(simulatorApp)) {
openArgs = [simulatorApp, '--args', '-CurrentDeviceUDID', udid];
} else if (await pathExists(deviceHubApp)) {
openArgs = [`devices://device/open?id=${udid}`];
} else {
throw new Exception(`Unable to find Simulator.app or DeviceHub.app in ${xCodePath}`);
}

const openResult = spawnSync('open', openArgs, { encoding: 'utf8' });

if (openResult.status) {
throw new Exception(`There was an error opening simulator: ${openResult.stderr}`);
}
Expand Down
Loading