Skip to content

Commit eb182f9

Browse files
fix: launchApplication fails when device identifier is passed
In case `launchApplication` is called with device identifier (instead of name), the validation fails as it expects a name. However, we already support starting and working with Id, so fix the validation. Also, in the past there was only one instance of a simulator running. When you wanted to start application on another simulator, we were killing the existing one and starting the new one. This is no longer required as multiple iOS Simulators may be running simultaneously. So remove the logic for killing the simulator
1 parent a2217f6 commit eb182f9

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
4545
}
4646

4747
public run(applicationPath: string, applicationIdentifier: string, options: IOptions): string {
48-
let device = this.getDeviceToRun(options);
49-
let currentBootedDevice = _.find(this.getDevices(), device => this.isDeviceBooted(device));
50-
if (currentBootedDevice && (currentBootedDevice.name.toLowerCase() !== device.name.toLowerCase() || currentBootedDevice.runtimeVersion !== device.runtimeVersion)) {
51-
this.killSimulator();
52-
}
48+
const device = this.getDeviceToRun(options);
5349

5450
this.startSimulator(options, device);
5551
if (!options.skipInstall) {
@@ -210,7 +206,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
210206
if (!this.isDeviceBooted(device)) {
211207
const isSimulatorAppRunning = this.isSimulatorAppRunning();
212208
const haveBootedDevices = this.haveBootedDevices();
213-
209+
214210
if (isSimulatorAppRunning) {
215211
// In case user closes simulator window but simulator app is still alive
216212
if (!haveBootedDevices) {

lib/iphone-simulator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class iPhoneSimulator implements IiPhoneSimulator {
2424
}
2525

2626
if (options.device) {
27-
let deviceNames = _.unique(_.map(this.simulator.getDevices(), (device: IDevice) => device.name));
28-
if (!_.contains(deviceNames, options.device)) {
29-
errors.fail(`Unable to find device ${options.device}. The valid device names are ${deviceNames.join(", ")}`);
27+
const hasSuchDevice = _.find(this.simulator.getDevices(), device => device.name === options.device || device.id === options.device);
28+
if (!hasSuchDevice) {
29+
errors.fail(`Unable to find device ${options.device}.`);
3030
}
3131
}
3232

0 commit comments

Comments
 (0)