diff --git a/packages/rn-tester/BUCK b/packages/rn-tester/BUCK index 01653b0589..3e577b4b78 100644 --- a/packages/rn-tester/BUCK +++ b/packages/rn-tester/BUCK @@ -1,3 +1,4 @@ +load("@fbsource//xplat/hermes/defs:hermes.bzl", "HERMES_BYTECODE_VERSION") load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") load("//tools/build_defs:fb_xplat_platform_specific_rule.bzl", "fb_xplat_platform_specific_rule") load("//tools/build_defs:fb_xplat_resource.bzl", "fb_xplat_resource") @@ -121,7 +122,9 @@ fb_apple_test( "QuartzCore", "UIKit", ], - preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), + preprocessor_flags = get_objc_arc_preprocessor_flags() + [ + "-DHERMES_BYTECODE_VERSION={}".format(HERMES_BYTECODE_VERSION), + ] + get_preprocessor_flags_for_build_mode(), visibility = [ "//fbobjc/Libraries/FBReactKit:workspace", ], diff --git a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m index 309ccaa6a1..9a72c65def 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m @@ -22,22 +22,42 @@ static NSURL *mainBundleURL() static NSURL *localhostBundleURL() { +#ifdef HERMES_BYTECODE_VERSION + return [NSURL + URLWithString: + [NSString + stringWithFormat: + @"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&runtimeBytecodeVersion=%u&app=com.apple.dt.xctest.tool", + testFile, + HERMES_BYTECODE_VERSION]]; +#else return [NSURL URLWithString: [NSString stringWithFormat: @"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", testFile]]; +#endif } static NSURL *ipBundleURL() { +#ifdef HERMES_BYTECODE_VERSION + return [NSURL + URLWithString: + [NSString + stringWithFormat: + @"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&runtimeBytecodeVersion=%u&app=com.apple.dt.xctest.tool", + testFile, + HERMES_BYTECODE_VERSION]]; +#else return [NSURL URLWithString: [NSString stringWithFormat: @"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", testFile]]; +#endif } @implementation NSBundle (RCTBundleURLProviderTests) @@ -88,6 +108,8 @@ static NSURL *ipBundleURL() - (void)testLocalhostURL { + id classMock = OCMClassMock([RCTBundleURLProvider class]); + [[[classMock stub] andReturnValue:@YES] isPackagerRunning:[OCMArg any] scheme:[OCMArg any]]; RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings]; settings.jsLocation = @"localhost"; NSURL *URL = [settings jsBundleURLForBundleRoot:testFile fallbackResource:nil];