Fix RNTester on iOS (#24736)

Summary:
See e94b116d76 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
This commit is contained in:
cpojer
2019-05-08 19:32:41 -07:00
committed by Facebook Github Bot
parent 3163479e0f
commit e7ebb17452
6 changed files with 14 additions and 14 deletions

View File

@@ -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"];

View File

@@ -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",

View File

@@ -144,8 +144,8 @@
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "CI_USE_BUNDLE_PREFIX"
value = "0"
key = "RN_BUNDLE_PREFIX"
value = ""
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>

View File

@@ -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];

View File

@@ -60,5 +60,7 @@
<false/>
<key>NSPhotoLibraryUsageDescription</key>
<string>You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*!</string>
<key>RN_BUNDLE_PREFIX</key>
<string>$(RN_BUNDLE_PREFIX)</string>
</dict>
</plist>

View File

@@ -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 {