Skip to content

Commit 56e3abb

Browse files
Merge pull request #107 from telerik/vladimirov/fix-run-device
fix: launchApplication fails when device identifier is passed
2 parents a2217f6 + f5d7b8b commit 56e3abb

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/iphone-simulator-xcode-simctl.ts

+2-6
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

+3-3
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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "3.4.2",
3+
"version": "3.4.3",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {

0 commit comments

Comments
 (0)