Skip to content

Commit a11606d

Browse files
Fix starting default simulator
In case device.id is not passed, we should start the default simulator (iPhone 6 for example). However, we are searching for device with id 'undefined' and we fail. Skip the verification in case device.id is not specified.
1 parent 460f2b2 commit a11606d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
9393
try {
9494
const xcodeVersion = xcode.getXcodeVersionData();
9595
xcodeMajorVersion = +xcodeVersion.major;
96-
} catch(err) {
96+
} catch (err) {
9797
// Ignore the error.
9898
}
9999

@@ -165,7 +165,10 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
165165
public startSimulator(device?: IDevice): void {
166166
device = device || this.getDeviceToRun();
167167

168-
this.verifyDevice(device);
168+
// In case the id is undefined, skip verification - we'll start default simulator.
169+
if (device.id) {
170+
this.verifyDevice(device);
171+
}
169172

170173
if (!this.isDeviceBooted(device)) {
171174
let bootedDevice = this.getBootedDevice();
@@ -181,9 +184,8 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
181184
}
182185
}
183186

184-
private verifyDevice(device?: IDevice): void {
187+
private verifyDevice(device: IDevice): void {
185188
const availableDevices = this.getDevices();
186-
187189
if (!_.find(availableDevices, { id: device.id })) {
188190
errors.fail(`No simulator image available for device identifier '${device.id}'.`);
189191
}

0 commit comments

Comments
 (0)