diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.mm b/packages/react-native/React/Base/RCTBundleURLProvider.mm index 7b5dd2b3641feb..aa8753376e1d1a 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.mm +++ b/packages/react-native/React/Base/RCTBundleURLProvider.mm @@ -7,6 +7,7 @@ #import "RCTBundleURLProvider.h" +#import "RCTConstants.h" #import "RCTConvert.h" #import "RCTDefines.h" #import "RCTLog.h" @@ -22,7 +23,6 @@ void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed) kRCTAllowPackagerAccess = allowed; } #endif -static NSString *const kRCTPlatformName = @"ios"; static NSString *const kRCTPackagerSchemeKey = @"RCT_packager_scheme"; static NSString *const kRCTJsLocationKey = @"RCT_jsLocation"; static NSString *const kRCTEnableDevKey = @"RCT_enableDev"; @@ -307,7 +307,7 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot NSString *path = [NSString stringWithFormat:@"/%@.bundle", bundleRoot]; BOOL lazy = enableDev; NSArray *queryItems = @[ - [[NSURLQueryItem alloc] initWithName:@"platform" value:kRCTPlatformName], + [[NSURLQueryItem alloc] initWithName:@"platform" value:RCTPlatformName], [[NSURLQueryItem alloc] initWithName:@"dev" value:enableDev ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"lazy" value:lazy ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"minify" value:enableMinification ? @"true" : @"false"], diff --git a/packages/react-native/React/Base/RCTConstants.h b/packages/react-native/React/Base/RCTConstants.h index af412e376f128c..54d3a470543a57 100644 --- a/packages/react-native/React/Base/RCTConstants.h +++ b/packages/react-native/React/Base/RCTConstants.h @@ -7,6 +7,8 @@ #import +RCT_EXTERN NSString *const RCTPlatformName; + RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotification; RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey; diff --git a/packages/react-native/React/Base/RCTConstants.m b/packages/react-native/React/Base/RCTConstants.m index 0ba6d2e00bcb47..056f6095d8fc06 100644 --- a/packages/react-native/React/Base/RCTConstants.m +++ b/packages/react-native/React/Base/RCTConstants.m @@ -7,6 +7,8 @@ #import "RCTConstants.h" +NSString *const RCTPlatformName = @"ios"; + NSString *const RCTUserInterfaceStyleDidChangeNotification = @"RCTUserInterfaceStyleDidChangeNotification"; NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey = @"traitCollection"; diff --git a/packages/react-native/React/CoreModules/RCTDevSettings.mm b/packages/react-native/React/CoreModules/RCTDevSettings.mm index f95e963fb29d5b..346738bccb6362 100644 --- a/packages/react-native/React/CoreModules/RCTDevSettings.mm +++ b/packages/react-native/React/CoreModules/RCTDevSettings.mm @@ -479,9 +479,10 @@ - (void)setupHMRClientWithBundleURL:(NSURL *)bundleURL NSNumber *const port = urlComponents.port; NSString *const scheme = urlComponents.scheme; BOOL isHotLoadingEnabled = self.isHotLoadingEnabled; - [self.callableJSModules invokeModule:@"HMRClient" - method:@"setup" - withArgs:@[ @"ios", path, host, RCTNullIfNil(port), @(isHotLoadingEnabled), scheme ]]; + [self.callableJSModules + invokeModule:@"HMRClient" + method:@"setup" + withArgs:@[ RCTPlatformName, path, host, RCTNullIfNil(port), @(isHotLoadingEnabled), scheme ]]; } } diff --git a/packages/react-native/React/DevSupport/RCTPackagerConnection.mm b/packages/react-native/React/DevSupport/RCTPackagerConnection.mm index 08c0ca1dd445ec..bd4075ca1b3294 100644 --- a/packages/react-native/React/DevSupport/RCTPackagerConnection.mm +++ b/packages/react-native/React/DevSupport/RCTPackagerConnection.mm @@ -14,6 +14,7 @@ #import #import #import +#import #import #import #import @@ -100,7 +101,7 @@ - (instancetype)init components.scheme = scheme; components.port = serverPort ? @(serverPort.integerValue) : @(kRCTBundleURLProviderDefaultPort); components.path = @"/message"; - components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"role" value:@"ios"] ]; + components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"role" value:RCTPlatformName] ]; static dispatch_queue_t queue; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ diff --git a/packages/rn-tester/RCTTest/RCTTestRunner.m b/packages/rn-tester/RCTTest/RCTTestRunner.m index d373afe1976428..0c5d54c110c682 100644 --- a/packages/rn-tester/RCTTest/RCTTestRunner.m +++ b/packages/rn-tester/RCTTest/RCTTestRunner.m @@ -9,6 +9,7 @@ #import #import +#import #import #import #import @@ -87,8 +88,9 @@ - (instancetype)initWithApp:(NSString *)app - (NSURL *)defaultScriptURL { if (getenv("CI_USE_PACKAGER") || _useBundler) { - return [NSURL - URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", _appPath]]; + return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=%@&dev=true", + _appPath, + RCTPlatformName]]; } else { return [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; } diff --git a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m index 5aa954c70e70be..0d363edbe479c2 100644 --- a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m +++ b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m @@ -9,6 +9,7 @@ #import #import +#import #import // Time to wait for an expected log statement to show before failing the test @@ -32,8 +33,9 @@ - (void)setUp NSURL *scriptURL; if (getenv("CI_USE_PACKAGER")) { NSString *app = @"IntegrationTests/IntegrationTestsApp"; - scriptURL = - [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]]; + scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=%@&dev=true", + app, + RCTPlatformName]]; } else { scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; } diff --git a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m index 596dceb191be1f..6d1fb5e1cf47e0 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m @@ -8,6 +8,7 @@ #import #import +#import #import #import "OCMock/OCMock.h" @@ -26,8 +27,9 @@ URLWithString: [NSString stringWithFormat: - @"http://localhost:8081/%@.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", - testFile]]; + @"http://localhost:8081/%@.bundle?platform=%@&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", + testFile, + RCTPlatformName]]; } static NSURL *ipBundleURL(void) @@ -36,8 +38,9 @@ URLWithString: [NSString stringWithFormat: - @"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", - testFile]]; + @"http://192.168.1.1:8081/%@.bundle?platform=%@&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", + testFile, + RCTPlatformName]]; } @implementation NSBundle (RCTBundleURLProviderTests)