Skip to content

Commit

Permalink
Fix Open Debugger dev menu item missing from iOS Bridgeless
Browse files Browse the repository at this point in the history
Summary:
After a [recent change](90296be) we break part of the integration with the debug menu, which is was using the presence/absence of the bridge to decide whether we were in bridge or bridgeless.

For backward compatibility reasosn, the bridge ivar is now populated with the bridgeProxy, so just checking whether is nil or not is not enough to verify whether we are in bridge or in bridgeless mode anymore.

## Changelog:
[iOS][Fixed] - Make sure that the Open Debugger appears in bridgeless mode

Reviewed By: fkgozali

Differential Revision: D56067897

fbshipit-source-id: e2501ed730ff35bc755c24ef400130c551032e28
  • Loading branch information
cipolleschi authored and huntie committed Apr 15, 2024
1 parent 0b3ebdf commit bb5451b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/react-native/React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ + (BOOL)requiresMainQueueSetup
return NO;
}

- (BOOL)_isBridgeMode
{
return [self.bridge isKindOfClass:[RCTBridge class]];
}

- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
{
if (self = [super init]) {
Expand All @@ -178,7 +183,7 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bb5451b

Please sign in to comment.