@@ -220,6 +220,11 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
220
220
return _ . find ( devices , device => this . isDeviceBooted ( device ) ) ;
221
221
}
222
222
223
+ private getBootedDevices ( ) : IDevice [ ] {
224
+ const devices = this . simctl . getDevices ( ) ;
225
+ return _ . filter ( devices , device => this . isDeviceBooted ( device ) ) ;
226
+ }
227
+
223
228
public startSimulator ( device ?: IDevice ) : void {
224
229
device = device || this . getDeviceToRun ( ) ;
225
230
@@ -229,15 +234,17 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
229
234
}
230
235
231
236
if ( ! this . isDeviceBooted ( device ) ) {
232
- let bootedDevice = this . getBootedDevice ( ) ;
233
- if ( bootedDevice && bootedDevice . id !== device . id ) {
234
- this . killSimulator ( ) ;
235
- }
236
-
237
- // In case user closes simulator window but simulator app is still alive
238
- if ( ! bootedDevice && this . isSimulatorAppRunning ( ) ) {
239
- const defaultDevice = _ . find ( this . simctl . getDevices ( ) , device => device . name === this . defaultDeviceIdentifier ) ;
240
- this . simctl . boot ( defaultDevice . id ) ;
237
+ const isSimulatorAppRunning = this . isSimulatorAppRunning ( ) ;
238
+ const haveBootedDevices = this . haveBootedDevices ( ) ;
239
+
240
+ if ( isSimulatorAppRunning ) {
241
+ // In case user closes simulator window but simulator app is still alive
242
+ if ( ! haveBootedDevices ) {
243
+ device = this . getDeviceToRun ( ) ;
244
+ }
245
+ this . simctl . boot ( device . id ) ;
246
+ } else {
247
+ common . startSimulator ( device . id ) ;
241
248
}
242
249
243
250
common . startSimulator ( device . id ) ;
@@ -248,6 +255,11 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
248
255
}
249
256
}
250
257
258
+ private haveBootedDevices ( ) : boolean {
259
+ const bootedDevices = this . getBootedDevices ( ) ;
260
+ return bootedDevices && bootedDevices . length > 0 ;
261
+ }
262
+
251
263
private isSimulatorAppRunning ( ) : boolean {
252
264
const simulatorAppName = "Simulator" ;
253
265
0 commit comments