Skip to content

Commit b80923b

Browse files
Merge pull request #92 from telerik/kddimitrov/fix-no-device-identifier-check
Fix simulator identifier not verified before startEmulator.
2 parents 2cdaa87 + 12f123a commit b80923b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/ios-sim.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Object.defineProperty(publicApi, "getInstalledApplications", {
5959
"printDeviceLog",
6060
"getDeviceLogProcess",
6161
"startSimulator",
62-
"getSimulatorName"].forEach(methodName => {
62+
"getSimulatorName",
63+
"getDevices"].forEach(methodName => {
6364
Object.defineProperty(publicApi, methodName, {
6465
get: () => {
6566
return (...args: any[]) => {

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
164164

165165
public startSimulator(device?: IDevice): void {
166166
device = device || this.getDeviceToRun();
167+
168+
this.verifyDevice(device);
169+
167170
if (!this.isDeviceBooted(device)) {
168171
let bootedDevice = this.getBootedDevice();
169172
if (bootedDevice && bootedDevice.id !== device.id) {
@@ -178,6 +181,14 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
178181
}
179182
}
180183

184+
private verifyDevice(device?: IDevice): void {
185+
const availableDevices = this.getDevices();
186+
187+
if (!_.find(availableDevices, { id: device.id })) {
188+
errors.fail(`No simulator image available for device identifier '${device.id}'.`);
189+
}
190+
}
191+
181192
private killSimulator(): void {
182193
childProcess.execSync("pkill -9 -f Simulator");
183194
}

0 commit comments

Comments
 (0)