From e7ebb17452e3796324505b2b92ceae728ca3eb64 Mon Sep 17 00:00:00 2001 From: cpojer Date: Wed, 8 May 2019 19:32:41 -0700 Subject: [PATCH] Fix RNTester on iOS (#24736) Summary: See e94b116d7675399af719ac58e36d3274a23feea4 which broke RNTester in open source. Environment variables are always strings, so "0" is a truthy value. This fixes it. [iOS] [fixed] - Fixed broken RNTester Pull Request resolved: https://github.com/facebook/react-native/pull/24736 Reviewed By: fkgozali Differential Revision: D15272951 Pulled By: hramos fbshipit-source-id: aa78f229e05cb553f75cdf6fb4f926829e20a557 --- RNTester/RCTTest/RCTTestRunner.m | 5 +---- RNTester/RNTester.xcodeproj/project.pbxproj | 7 +++++++ .../xcshareddata/xcschemes/RNTester.xcscheme | 4 ++-- RNTester/RNTester/AppDelegate.mm | 5 +---- RNTester/RNTester/Info.plist | 2 ++ RNTester/RNTesterIntegrationTests/RCTLoggingTests.m | 5 +---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/RNTester/RCTTest/RCTTestRunner.m b/RNTester/RCTTest/RCTTestRunner.m index 3e530a5e1..bf2228c0a 100644 --- a/RNTester/RCTTest/RCTTestRunner.m +++ b/RNTester/RCTTest/RCTTestRunner.m @@ -87,10 +87,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) - (NSURL *)defaultScriptURL { if (getenv("CI_USE_PACKAGER") || _useBundler) { - NSString *bundlePrefix = @""; - if (getenv("CI_USE_BUNDLE_PREFIX")) { - bundlePrefix = @"react-native-github/"; - } + NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, _appPath]]; } else { return [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/RNTester/RNTester.xcodeproj/project.pbxproj b/RNTester/RNTester.xcodeproj/project.pbxproj index f25ba253c..e2288089c 100644 --- a/RNTester/RNTester.xcodeproj/project.pbxproj +++ b/RNTester/RNTester.xcodeproj/project.pbxproj @@ -1913,6 +1913,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js"; DEVELOPMENT_TEAM = VYK7DLU38Z; + GCC_PREPROCESSOR_DEFINITIONS = ( + "RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)", + "DEBUG=1", + "$(inherited)", + ); HEADER_SEARCH_PATHS = ( "$(SRCROOT)/../third-party/boost_1_63_0", "$(SRCROOT)/../third-party/folly-2018.10.22.00", @@ -1924,6 +1929,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp; PRODUCT_NAME = RNTester; + RN_BUNDLE_PREFIX = ""; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1934,6 +1940,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js"; DEVELOPMENT_TEAM = VYK7DLU38Z; + GCC_PREPROCESSOR_DEFINITIONS = "RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)"; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/../third-party/boost_1_63_0", "$(SRCROOT)/../third-party/folly-2018.10.22.00", diff --git a/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme b/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme index 4f65fc298..ff2e9c27c 100644 --- a/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme +++ b/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme @@ -144,8 +144,8 @@ isEnabled = "YES"> diff --git a/RNTester/RNTester/AppDelegate.mm b/RNTester/RNTester/AppDelegate.mm index 4e11db008..17f089a43 100644 --- a/RNTester/RNTester/AppDelegate.mm +++ b/RNTester/RNTester/AppDelegate.mm @@ -109,10 +109,7 @@ - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { - NSString *bundlePrefix = @""; - if (getenv("CI_USE_BUNDLE_PREFIX")) { - bundlePrefix = @"react-native-github/"; - } + NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; NSString *bundleRoot = [NSString stringWithFormat:@"%@RNTester/js/RNTesterApp.ios", bundlePrefix]; return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot fallbackResource:nil]; diff --git a/RNTester/RNTester/Info.plist b/RNTester/RNTester/Info.plist index 13573d49b..3b0806d0b 100644 --- a/RNTester/RNTester/Info.plist +++ b/RNTester/RNTester/Info.plist @@ -60,5 +60,7 @@ NSPhotoLibraryUsageDescription You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*! + RN_BUNDLE_PREFIX + $(RN_BUNDLE_PREFIX) diff --git a/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m b/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m index 8cc22ef0e..e1ed8b0b8 100644 --- a/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m +++ b/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m @@ -30,10 +30,7 @@ { NSURL *scriptURL; if (getenv("CI_USE_PACKAGER")) { - NSString *bundlePrefix = @""; - if (getenv("CI_USE_BUNDLE_PREFIX")) { - bundlePrefix = @"react-native-github/"; - } + NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"]; NSString *app = @"IntegrationTests/IntegrationTestsApp"; scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, app]]; } else {