Skip to content

Commit 94380cb

Browse files
fmacinatormeta-codesync[bot]
authored andcommitted
Gate Metro connectivity on RCT_DEV_MENU instead of RCT_DEV (#57080)
Summary: Pull Request resolved: #57080 When an iOS app is built with the React Native dev menu enabled (`RCT_DEV_MENU=1`) but `RCT_DEV=0`, the "Change Bundle Location" option can be visible while the Metro connection path remains compiled out. This makes the setting ineffective. This gates the Metro host override path on `RCT_DEV_MENU` instead of `RCT_DEV`, matching the flag that controls whether the dev menu exists. Auto-discovery via `guessPackagerHost` remains behind `RCT_DEV` because it is a development convenience for full dev builds. Builds that do not set `RCT_DEV_MENU=1` keep the same preprocessor output because `RCT_DEV_MENU` defaults to `RCT_DEV`. Changelog: [iOS][Fixed] - Allow iOS apps with the dev menu enabled (`RCT_DEV_MENU`) to connect to Metro via "Change Bundle Location" Reviewed By: huntie Differential Revision: D107524388 fbshipit-source-id: 9d1281c6829b50ca45be9deba0d37e10d6466ee2
1 parent d53c7b5 commit 94380cb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/react-native/React/Base/RCTBundleURLProvider.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
2121

22-
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
22+
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
2323
static BOOL kRCTAllowPackagerAccess = YES;
2424
void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed)
2525
{
@@ -81,7 +81,7 @@ - (void)resetToDefaults
8181
(unsigned long)kRCTBundleURLProviderDefaultPort]];
8282
}
8383

84-
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
84+
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
8585
+ (BOOL)isPackagerRunning:(NSString *)hostPort
8686
{
8787
return [RCTBundleURLProvider isPackagerRunning:hostPort scheme:nil];
@@ -258,14 +258,14 @@ - (NSString *)packagerServerHost
258258

259259
- (NSString *)packagerServerHostPort
260260
{
261-
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
261+
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
262262
if (!kRCTAllowPackagerAccess) {
263263
RCTLogInfo(@"Packager server access is disabled in this environment");
264264
return nil;
265265
}
266266
#endif
267267
NSString *location = [self jsLocation];
268-
#if RCT_DEV
268+
#if RCT_DEV_MENU
269269
NSString *scheme = [self packagerScheme];
270270
if ([location length] && ![RCTBundleURLProvider isPackagerRunning:location scheme:scheme]) {
271271
location = nil;

0 commit comments

Comments
 (0)