mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Gate Metro connectivity on RCT_DEV_MENU instead of RCT_DEV (#57080)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
1 parent
d53c7b52a6
commit
94380cb4ad
1 file changed
+4
-4
@@ -19,7 +19,7 @@ NSString *const RCTBundleURLProviderUpdatedNotification = @"RCTBundleURLProvider
|
||||
|
||||
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
|
||||
|
||||
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
static BOOL kRCTAllowPackagerAccess = YES;
|
||||
void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed)
|
||||
{
|
||||
@@ -81,7 +81,7 @@ static NSURL *serverRootWithHostPort(NSString *hostPort, NSString *scheme)
|
||||
(unsigned long)kRCTBundleURLProviderDefaultPort]];
|
||||
}
|
||||
|
||||
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
+ (BOOL)isPackagerRunning:(NSString *)hostPort
|
||||
{
|
||||
return [RCTBundleURLProvider isPackagerRunning:hostPort scheme:nil];
|
||||
@@ -258,14 +258,14 @@ static NSURL *serverRootWithHostPort(NSString *hostPort, NSString *scheme)
|
||||
|
||||
- (NSString *)packagerServerHostPort
|
||||
{
|
||||
#if RCT_DEV | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
if (!kRCTAllowPackagerAccess) {
|
||||
RCTLogInfo(@"Packager server access is disabled in this environment");
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
NSString *location = [self jsLocation];
|
||||
#if RCT_DEV
|
||||
#if RCT_DEV_MENU
|
||||
NSString *scheme = [self packagerScheme];
|
||||
if ([location length] && ![RCTBundleURLProvider isPackagerRunning:location scheme:scheme]) {
|
||||
location = nil;
|
||||
|
||||
Reference in new issue
Block a user