diff --git a/packages/react-native/React/CoreModules/RCTDevSettings.mm b/packages/react-native/React/CoreModules/RCTDevSettings.mm index 10930504894a4b..887a69c06c1b37 100644 --- a/packages/react-native/React/CoreModules/RCTDevSettings.mm +++ b/packages/react-native/React/CoreModules/RCTDevSettings.mm @@ -158,6 +158,11 @@ + (BOOL)requiresMainQueueSetup return NO; } +- (BOOL)_isBridgeMode +{ + return [self.bridge isKindOfClass:[RCTBridge class]]; +} + - (instancetype)initWithDataSource:(id)dataSource { if (self = [super init]) { @@ -178,7 +183,7 @@ - (instancetype)initWithDataSource:(id)dataSource - (void)initialize { #if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION - if (self.bridge) { + if ([self _isBridgeMode]) { RCTBridge *__weak weakBridge = self.bridge; _bridgeExecutorOverrideToken = [[RCTPackagerConnection sharedPackagerConnection] addNotificationHandler:^(id params) { @@ -209,7 +214,7 @@ - (void)initialize #endif #if RCT_ENABLE_INSPECTOR - if (self.bridge) { + if ([self _isBridgeMode]) { // We need this dispatch to the main thread because the bridge is not yet // finished with its initialisation. By the time it relinquishes control of // the main thread, this operation can be performed. @@ -250,7 +255,7 @@ - (void)invalidate { [super invalidate]; #if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION - if (self.bridge) { + if ([self _isBridgeMode]) { [[RCTPackagerConnection sharedPackagerConnection] removeHandler:_bridgeExecutorOverrideToken]; } @@ -281,7 +286,7 @@ - (id)settingForKey:(NSString *)key - (BOOL)isDeviceDebuggingAvailable { #if RCT_ENABLE_INSPECTOR - if (self.bridge) { + if ([self _isBridgeMode]) { return self.bridge.isInspectable; } else { return self.isInspectable;