@@ -40,11 +40,11 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
40
40
} ) ;
41
41
}
42
42
43
- public run ( applicationPath : string , applicationIdentifier : string ) : void {
43
+ public async run ( applicationPath : string , applicationIdentifier : string ) : void {
44
44
let device = this . getDeviceToRun ( ) ;
45
45
let currentBootedDevice = _ . find ( this . getDevices ( ) , device => this . isDeviceBooted ( device ) ) ;
46
46
if ( currentBootedDevice && ( currentBootedDevice . name . toLowerCase ( ) !== device . name . toLowerCase ( ) || currentBootedDevice . runtimeVersion !== device . runtimeVersion ) ) {
47
- this . killSimulator ( ) ;
47
+ await this . killSimulator ( ) ;
48
48
}
49
49
50
50
this . startSimulator ( device ) ;
@@ -145,9 +145,14 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
145
145
return _ . find ( devices , device => this . isDeviceBooted ( device ) ) ;
146
146
}
147
147
148
- public startSimulator ( device ?: IDevice ) : void {
148
+ public async startSimulator ( device ?: IDevice ) : void {
149
149
device = device || this . getDeviceToRun ( ) ;
150
150
if ( ! this . isDeviceBooted ( device ) ) {
151
+ let bootedDevice = this . getBootedDevice ( ) ;
152
+ if ( bootedDevice && bootedDevice . id !== device . id ) {
153
+ await this . killSimulator ( ) ;
154
+ }
155
+
151
156
common . startSimulator ( device . id ) ;
152
157
// startSimulaltor doesn't always finish immediately, and the subsequent
153
158
// install fails since the simulator is not running.
@@ -156,7 +161,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
156
161
}
157
162
}
158
163
159
- private killSimulator ( ) : Promise < any > {
164
+ private async killSimulator ( ) : Promise < any > {
160
165
return childProcess . spawn ( "pkill" , [ "-9" , "-f" , "Simulator" ] ) ;
161
166
}
162
- }
167
+ }
0 commit comments