@@ -127,7 +127,7 @@ - (NSString *)installApplicationWithHost:(NSString *)testHost withError:(NSError
127
127
}];
128
128
return nil ;
129
129
} else {
130
- [self shutdownSimulatorWithError : errPtr];
130
+ [self shutdownSimulator: simDevice withError : errPtr];
131
131
if (*errPtr) {
132
132
[BPUtils printInfo: ERROR withString: @" Shutdown simulator failed with error: %@ " , [*errPtr localizedDescription ]];
133
133
[deviceSet deleteDeviceAsync: simDevice completionHandler: ^(NSError *error) {
@@ -307,17 +307,20 @@ - (BOOL)useSimulatorWithDeviceUDID:(NSUUID *)deviceUDID {
307
307
return YES ;
308
308
}
309
309
310
- - (BOOL )shutdownSimulatorWithError : (id *)error {
311
- [BPUtils printInfo: INFO withString: @" Starting Safe Shutdown of %@ " , self .device.UDID.UUIDString];
310
+ - (BOOL )shutdownSimulator : (SimDevice *)simDevice withError : (id *)error {
311
+ if (!simDevice) {
312
+ return NO ;
313
+ }
314
+ [BPUtils printInfo: INFO withString: @" Starting Safe Shutdown of %@ " , simDevice.UDID.UUIDString];
312
315
313
316
// Calling shutdown when already shutdown should be avoided (if detected).
314
- if ([self .device .stateString isEqualToString: @" Shutdown" ]) {
315
- [BPUtils printInfo: INFO withString: @" Shutdown of %@ succeeded as it is already shutdown" , self .device ];
317
+ if ([simDevice .stateString isEqualToString: @" Shutdown" ]) {
318
+ [BPUtils printInfo: INFO withString: @" Shutdown of %@ succeeded as it is already shutdown" , simDevice ];
316
319
*error = nil ;
317
320
return YES ;
318
321
}
319
322
320
- return [self .device shutdownWithError: error];
323
+ return [simDevice shutdownWithError: error];
321
324
}
322
325
323
326
- (void )bootWithCompletion : (void (^)(NSError *error))completion {
@@ -333,7 +336,7 @@ - (void)openSimulatorHeadlessWithCompletion:(void (^)(NSError *))completion {
333
336
[self .device bootAsyncWithOptions: options completionHandler: ^(NSError *bootError){
334
337
NSError *error = [self waitForDeviceReady ];
335
338
if (error) {
336
- [self shutdownSimulatorWithError : &error];
339
+ [self shutdownSimulator: self .device withError : &error];
337
340
if (error) {
338
341
[BPUtils printInfo: ERROR withString: @" Shutting down Simulator failed: %@ " , [error localizedDescription ]];
339
342
}
@@ -584,7 +587,7 @@ - (void)deleteSimulatorWithCompletion:(void (^)(NSError *error, BOOL success))co
584
587
}
585
588
if (self.device ) {
586
589
[BPUtils printInfo: INFO withString: @" Shutting down Simulator" ];
587
- [self shutdownSimulatorWithError : &error];
590
+ [self shutdownSimulator: self .device withError : &error];
588
591
if (error) {
589
592
[BPUtils printInfo: ERROR withString: @" Shutting down Simulator failed: %@ " , [error localizedDescription ]];
590
593
completion (error, NO );
0 commit comments