Skip to content

Commit a6ea626

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Remove the option to use JSC from core (#51946)
Summary: Pull Request resolved: #51946 This change simplified the setp disallowing to use JSC from core. As a side effect, it simplified the setup by always falling back to hermes if the users decides not to use the third party JSC ## Changelog: [iOS][Removed] - remove the option to use JSC from core Reviewed By: cortinico Differential Revision: D76342625 fbshipit-source-id: c925ab4fab1e171e289a1c5f75890c92da1b3f08
1 parent 1da608f commit a6ea626

File tree

23 files changed

+88
-195
lines changed

23 files changed

+88
-195
lines changed

packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313

1414
#import <memory>
1515

16-
#if USE_HERMES
16+
#if USE_THIRD_PARTY_JSC != 1
1717
#if __has_include(<jsireact/HermesExecutorFactory.h>)
1818
#import <jsireact/HermesExecutorFactory.h>
1919
#elif __has_include(<reacthermes/HermesExecutorFactory.h>)
2020
#import <reacthermes/HermesExecutorFactory.h>
2121
#endif
22-
#elif USE_THIRD_PARTY_JSC != 1
23-
#import <React/JSCExecutorFactory.h>
24-
#endif // USE_HERMES
22+
#endif
2523

2624
#import <ReactCommon/RCTTurboModuleManager.h>
2725
#import <jsireact/JSIExecutor.h>

packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,10 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
145145
}
146146
[turboModuleManager installJSBindings:runtime];
147147
};
148-
#if USE_HERMES
148+
#if USE_THIRD_PARTY_JSC != 1
149149
return std::make_unique<facebook::react::HermesExecutorFactory>(
150150
facebook::react::RCTJSIExecutorRuntimeInstaller(runtimeInstallerLambda));
151-
#elif USE_THIRD_PARTY_JSC != 1
152-
return std::make_unique<facebook::react::JSCExecutorFactory>(
153-
facebook::react::RCTJSIExecutorRuntimeInstaller(runtimeInstallerLambda));
154-
#else
155-
throw std::runtime_error("No JSExecutorFactory specified.");
156-
return nullptr;
157-
#endif // USE_HERMES
151+
#endif
158152
}
159153

160154
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactoryForOldArch(
@@ -169,14 +163,8 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
169163
facebook::react::RuntimeSchedulerBinding::createAndInstallIfNeeded(runtime, runtimeScheduler);
170164
}
171165
};
172-
#if USE_HERMES
166+
#if USE_THIRD_PARTY_JSC != 1
173167
return std::make_unique<facebook::react::HermesExecutorFactory>(
174168
facebook::react::RCTJSIExecutorRuntimeInstaller(runtimeInstallerLambda));
175-
#elif USE_THIRD_PARTY_JSC != 1
176-
return std::make_unique<facebook::react::JSCExecutorFactory>(
177-
facebook::react::RCTJSIExecutorRuntimeInstaller(runtimeInstallerLambda));
178-
#else
179-
throw std::runtime_error("No JSExecutorFactory specified.");
180-
return nullptr;
181-
#endif // USE_HERMES
169+
#endif
182170
}

packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
#import <ReactCommon/RCTHost.h>
1010
#import "RCTAppSetupUtils.h"
1111
#import "RCTDependencyProvider.h"
12-
#if USE_HERMES
12+
#if USE_THIRD_PARTY_JSC != 1
1313
#import <React/RCTHermesInstanceFactory.h>
14-
#elif USE_THIRD_PARTY_JSC != 1
15-
#import <React/RCTJscInstanceFactory.h>
1614
#endif
1715

1816
#import <react/nativemodule/defaults/DefaultTurboModules.h>
@@ -45,12 +43,8 @@ - (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)
4543

4644
- (JSRuntimeFactoryRef)createJSRuntimeFactory
4745
{
48-
#if USE_HERMES
46+
#if USE_THIRD_PARTY_JSC != 1
4947
return jsrt_create_hermes_factory();
50-
#elif USE_THIRD_PARTY_JSC != 1
51-
return jsrt_create_jsc_factory();
52-
#else
53-
return nullptr;
5448
#endif
5549
}
5650

packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ else
1717
end
1818

1919
is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] != "0"
20-
use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
21-
2220
new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED=1" : "")
23-
hermes_flag = (use_hermes ? " -DUSE_HERMES=1" : "")
24-
use_third_party_jsc_flag = ENV['USE_THIRD_PARTY_JSC'] == '1' ? " -DUSE_THIRD_PARTY_JSC=1" : ""
25-
other_cflags = "$(inherited) " + new_arch_enabled_flag + hermes_flag + use_third_party_jsc_flag
21+
other_cflags = "$(inherited) " + new_arch_enabled_flag + js_engine_flags()
2622

2723
header_search_paths = [
2824
"$(PODS_TARGET_SRCROOT)/../../ReactCommon",
@@ -31,7 +27,7 @@ header_search_paths = [
3127
"$(PODS_ROOT)/Headers/Public/ReactCommon",
3228
"$(PODS_ROOT)/Headers/Public/React-RCTFabric",
3329
"$(PODS_ROOT)/Headers/Private/Yoga",
34-
].concat(use_hermes ? [
30+
].concat(use_hermes() ? [
3531
"$(PODS_ROOT)/Headers/Public/React-hermes",
3632
"$(PODS_ROOT)/Headers/Public/hermes-engine"
3733
] : [])
@@ -66,7 +62,7 @@ Pod::Spec.new do |s|
6662
s.dependency "React-CoreModules"
6763
s.dependency "React-RCTFBReactNativeSpec"
6864
s.dependency "React-defaultsnativemodule"
69-
if use_hermes
65+
if use_hermes()
7066
s.dependency 'React-hermes'
7167
end
7268

packages/react-native/Libraries/Blob/React-RCTBlob.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Pod::Spec.new do |s|
5050
add_dependency(s, "React-jsinspectorcdp", :framework_name => 'jsinspector_moderncdp')
5151
add_dependency(s, "ReactCommon", :subspec => "turbomodule/core", :additional_framework_paths => ["react/nativemodule/core"])
5252

53-
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
53+
if use_hermes()
5454
s.dependency "hermes-engine"
5555
end
5656

packages/react-native/React-Core.podspec

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ else
1616
source[:tag] = "v#{version}"
1717
end
1818

19-
use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
20-
use_hermes_flag = use_hermes ? "-DUSE_HERMES=1" : ""
21-
use_third_party_jsc_flag = ENV['USE_THIRD_PARTY_JSC'] == '1' ? "-DUSE_THIRD_PARTY_JSC=1" : ""
22-
2319
header_subspecs = {
2420
'CoreModulesHeaders' => 'React/CoreModules/**/*.h',
2521
'RCTActionSheetHeaders' => 'Libraries/ActionSheetIOS/*.h',
@@ -35,7 +31,7 @@ header_subspecs = {
3531
}
3632

3733
frameworks_search_paths = []
38-
frameworks_search_paths << "\"$(PODS_CONFIGURATION_BUILD_DIR)/React-hermes\"" if use_hermes
34+
frameworks_search_paths << "\"$(PODS_CONFIGURATION_BUILD_DIR)/React-hermes\"" if use_hermes()
3935

4036
header_search_paths = [
4137
"$(PODS_TARGET_SRCROOT)/ReactCommon",
@@ -56,7 +52,7 @@ Pod::Spec.new do |s|
5652
s.platforms = min_supported_versions
5753
s.source = source
5854
s.resource_bundle = { "RCTI18nStrings" => ["React/I18n/strings/*.lproj"]}
59-
s.compiler_flags = use_hermes_flag + ' ' + use_third_party_jsc_flag
55+
s.compiler_flags = js_engine_flags()
6056
s.header_dir = "React"
6157
s.weak_framework = "JavaScriptCore"
6258
s.pod_target_xcconfig = {
@@ -80,13 +76,9 @@ Pod::Spec.new do |s|
8076
"React/Inspector/**/*",
8177
"React/Runtime/**/*",
8278
]
83-
# If we are using Hermes (the default is use hermes, so USE_HERMES can be nil), we don't have jsc installed
84-
# So we have to exclude the JSCExecutorFactory
85-
if use_hermes
86-
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
87-
elsif ENV['USE_THIRD_PARTY_JSC'] == '1'
88-
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
89-
end
79+
80+
# The default is use hermes, we don't have jsc installed
81+
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
9082

9183
ss.exclude_files = exclude_files
9284
ss.private_header_files = "React/Cxx*/*.h"
@@ -123,7 +115,7 @@ Pod::Spec.new do |s|
123115
s.dependency "React-runtimescheduler"
124116
s.dependency "Yoga"
125117

126-
if use_hermes
118+
if use_hermes()
127119
s.dependency "React-hermes"
128120
end
129121

@@ -136,7 +128,6 @@ Pod::Spec.new do |s|
136128
add_dependency(s, "React-utils", :additional_framework_paths => ["react/utils/platform/ios"])
137129
add_dependency(s, "RCTDeprecation")
138130

139-
140131
depend_on_js_engine(s)
141132
add_rn_third_party_dependencies(s)
142133
end

packages/react-native/React/CxxBridge/RCTCxxBridge.mm

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@
4545
#import <react/utils/FollyConvert.h>
4646
#import <reactperflogger/BridgeNativeModulePerfLogger.h>
4747

48-
#if USE_HERMES
48+
#if !defined(USE_HERMES) || USE_HERMES == 1
4949
#import <reacthermes/HermesExecutorFactory.h>
50-
#elif USE_THIRD_PARTY_JSC != 1
51-
#import "JSCExecutorFactory.h"
5250
#endif
5351
#import "RCTJSIExecutorRuntimeInstaller.h"
5452

@@ -471,12 +469,8 @@ - (void)start
471469
}
472470
if (!executorFactory) {
473471
auto installBindings = RCTJSIExecutorRuntimeInstaller(nullptr);
474-
#if USE_HERMES
472+
#if !defined(USE_HERMES) || USE_HERMES == 1
475473
executorFactory = std::make_shared<HermesExecutorFactory>(installBindings);
476-
#elif USE_THIRD_PARTY_JSC != 1
477-
executorFactory = std::make_shared<JSCExecutorFactory>(installBindings);
478-
#else
479-
throw std::runtime_error("No JSExecutorFactory specified.");
480474
#endif
481475
}
482476
} else {
@@ -1144,7 +1138,9 @@ - (void)handleError:(NSError *)error
11441138
/**
11451139
* Prevent super from calling setUp (that'd create another batchedBridge)
11461140
*/
1147-
- (void)setUp {}
1141+
- (void)setUp
1142+
{
1143+
}
11481144

11491145
- (Class)executorClass
11501146
{

packages/react-native/React/Runtime/React-RCTRuntime.podspec

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ Pod::Spec.new do |s|
5858
add_dependency(s, "React-RuntimeCore")
5959
add_dependency(s, "React-RuntimeApple")
6060

61-
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
61+
if use_third_party_jsc()
62+
s.exclude_files = ["RCTHermesInstanceFactory.{mm,h}", "RCTJscInstanceFactory.{mm,h}"]
63+
else
6264
s.dependency "hermes-engine"
6365
add_dependency(s, "React-RuntimeHermes")
6466
s.exclude_files = "RCTJscInstanceFactory.{h,mm}"
65-
elsif ENV['USE_THIRD_PARTY_JSC'] == '1'
66-
s.exclude_files = ["RCTHermesInstanceFactory.{mm,h}", "RCTJscInstanceFactory.{mm,h}"]
67-
else
68-
s.exclude_files = ["RCTHermesInstanceFactory.{mm,h}"]
6967
end
68+
7069
depend_on_js_engine(s)
7170
add_rn_third_party_dependencies(s)
7271
end

packages/react-native/ReactCommon/ReactCommon.podspec

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ else
1616
source[:tag] = "v#{version}"
1717
end
1818

19-
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
20-
2119
Pod::Spec.new do |s|
2220
s.name = "ReactCommon"
2321
s.module_name = "ReactCommon"
@@ -48,7 +46,7 @@ Pod::Spec.new do |s|
4846
ss.dependency "React-cxxreact", version
4947
ss.dependency "React-jsi", version
5048
ss.dependency "React-logger", version
51-
if using_hermes
49+
if use_hermes()
5250
ss.dependency "hermes-engine"
5351
end
5452

@@ -58,7 +56,7 @@ Pod::Spec.new do |s|
5856
sss.exclude_files = "react/bridging/tests"
5957
sss.header_dir = "react/bridging"
6058
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
61-
if using_hermes
59+
if use_hermes()
6260
sss.dependency "hermes-engine"
6361
end
6462
end

packages/react-native/ReactCommon/cxxreact/React-cxxreact.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Pod::Spec.new do |s|
4848

4949
s.resource_bundles = {'React-cxxreact_privacy' => 'PrivacyInfo.xcprivacy'}
5050

51-
if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
51+
if use_hermes()
5252
s.dependency 'hermes-engine'
5353
end
5454

0 commit comments

Comments
 (0)