diff --git a/detox/ios/Detox/DetoxManager.m b/detox/ios/Detox/DetoxManager.m index 03de451a84..adc974a3ea 100644 --- a/detox/ios/Detox/DetoxManager.m +++ b/detox/ios/Detox/DetoxManager.m @@ -79,14 +79,24 @@ - (instancetype)init self.testRunner = [[TestRunner alloc] init]; self.testRunner.delegate = self; - if([ReactNativeSupport isReactNativeApp]) - { - [self _waitForRNLoadWithId:@0]; - } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_appDidLaunch:) name:UIApplicationDidFinishLaunchingNotification object:nil]; return self; } +- (void)_appDidLaunch:(NSNotification*)note +{ + [EarlGrey detox_safeExecuteSync:^{ + self.isReady = YES; + [self _sendGeneralReadyMessage]; + }]; +} + +- (void)_sendGeneralReadyMessage +{ + [self.webSocket sendAction:@"ready" withParams:@{} withMessageId:@-1000]; +} + - (void)connectToServer:(NSString*)url withSessionId:(NSString*)sessionId { [self.webSocket connectToServer:url withSessionId:sessionId]; @@ -205,7 +215,7 @@ - (void)_waitForRNLoadWithId:(id)messageId __weak __typeof(self) weakSelf = self; [ReactNativeSupport waitForReactNativeLoadWithCompletionHandler:^{ weakSelf.isReady = YES; - [weakSelf.webSocket sendAction:@"ready" withParams:@{} withMessageId:@-1000]; + [weakSelf _sendGeneralReadyMessage]; }]; } diff --git a/detox/ios/Detox/ReactNativeSupport.m b/detox/ios/Detox/ReactNativeSupport.m index ed750c3e0b..3a7b2326ee 100644 --- a/detox/ios/Detox/ReactNativeSupport.m +++ b/detox/ios/Detox/ReactNativeSupport.m @@ -114,13 +114,8 @@ void setupForTests() { wx_original_dispatch_queue_create = dlsym(RTLD_DEFAULT, "dispatch_queue_create"); - // Rebind symbols dispatch_* to point to our own implementation. - struct rebinding rebindings[] = { - {"dispatch_queue_create", wx_dispatch_queue_create, NULL} - }; - GREY_UNUSED_VARIABLE int failure = - rebind_symbols(rebindings, sizeof(rebindings) / sizeof(rebindings[0])); - NSCAssert(!failure, @"rebinding symbols failed"); + // Rebind symbols dispatch_queue_create to point to our own implementation. + rebind_symbols((struct rebinding[]){"dispatch_queue_create", wx_dispatch_queue_create, NULL}, 1); __currentIdlingResourceSerialQueue = dispatch_queue_create("__currentIdlingResourceSerialQueue", NULL);