Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 8d04d28

Browse files
Fix check for ios simulator
When we check if there is running simulator we use ps cax but if the simulator is killed for a short period of time after that there is a process listed when using ps cax and we decide that there is a running simulator and then we try to use it but ios-sim-portable returns null. We should check if the simulator returned from ios-sim-portable is not null or undefined in order to continue to work with it.
1 parent 8bb173c commit 8d04d28

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

mobile/mobile-core/ios-simulator-discovery.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery {
1818

1919
public checkForDevices(future?: IFuture<void>): IFuture<void> {
2020
if (this.$hostInfo.isDarwin) {
21-
if (this.isSimulatorRunning().wait()) {
22-
let currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator();
21+
let currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator();
2322

23+
if (currentSimulator) {
2424
if (!this.cachedSimulator) {
2525
this.createAndAddDevice(currentSimulator);
2626
} else if (this.cachedSimulator.id !== currentSimulator.id) {
@@ -41,20 +41,10 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery {
4141
return future || Future.fromResult();
4242
}
4343

44-
private isSimulatorRunning(): IFuture<boolean> {
45-
return (() => {
46-
try {
47-
let output = this.$childProcess.exec("ps cax | grep launchd_sim").wait();
48-
return output.indexOf('launchd_sim') !== -1;
49-
} catch(e) {
50-
return false;
51-
}
52-
}).future<boolean>()();
53-
}
54-
5544
private createAndAddDevice(simulator: Mobile.IiSimDevice): void {
5645
this.cachedSimulator = _.cloneDeep(simulator);
57-
this.addDevice(this.$injector.resolve(IOSSimulator, {simulator: this.cachedSimulator}));
46+
this.addDevice(this.$injector.resolve(IOSSimulator, { simulator: this.cachedSimulator }));
5847
}
5948
}
49+
6050
$injector.register("iOSSimulatorDiscovery", IOSSimulatorDiscovery);

0 commit comments

Comments
 (0)