From a93cce1e49bf7b8b3b15bde9777c1a4b53573c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 20 Oct 2022 06:55:10 -0700 Subject: [PATCH 1/4] Rename React-jsi to React-jsc Differential Revision: D40442603 fbshipit-source-id: 1690377f76bc7227a1e77e542059e6efac259b47 --- Libraries/Blob/React-RCTBlob.podspec | 2 +- Libraries/Image/React-RCTImage.podspec | 1 + Libraries/LinkingIOS/React-RCTLinking.podspec | 1 + .../React-RCTAnimation.podspec | 1 + Libraries/Network/React-RCTNetwork.podspec | 1 + .../React-RCTPushNotification.podspec | 1 + Libraries/Settings/React-RCTSettings.podspec | 1 + .../Vibration/React-RCTVibration.podspec | 1 + React-Core.podspec | 1 + React/CoreModules/React-CoreModules.podspec | 1 + .../FBReactNativeSpec.podspec | 1 + ReactCommon/React-Fabric.podspec | 1 + ReactCommon/React-bridging.podspec | 1 + ReactCommon/ReactCommon.podspec | 1 + ReactCommon/cxxreact/React-cxxreact.podspec | 1 + ReactCommon/hermes/React-hermes.podspec | 2 +- ReactCommon/jsi/React-jsc.podspec | 42 +++++++++++++++++++ ReactCommon/jsi/React-jsi.podspec | 28 ++----------- ReactCommon/jsi/React-jsidynamic.podspec | 1 + .../React-runtimeexecutor.podspec | 1 + .../rn-tester/RCTTest/React-RCTTest.podspec | 1 + .../cocoapods/__tests__/codegen_utils-test.rb | 1 + scripts/cocoapods/__tests__/fabric-test.rb | 11 ++++- scripts/cocoapods/codegen_utils.rb | 1 + scripts/cocoapods/fabric.rb | 20 ++++----- scripts/react_native_pods.rb | 1 + 26 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 ReactCommon/jsi/React-jsc.podspec diff --git a/Libraries/Blob/React-RCTBlob.podspec b/Libraries/Blob/React-RCTBlob.podspec index ee488e04aa142a..a4606fe2f06ee6 100644 --- a/Libraries/Blob/React-RCTBlob.podspec +++ b/Libraries/Blob/React-RCTBlob.podspec @@ -42,8 +42,8 @@ Pod::Spec.new do |s| s.dependency "React-Codegen", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTBlobHeaders", version s.dependency "React-Core/RCTWebSocket", version s.dependency "React-RCTNetwork", version - s.dependency "React-jsi", version end diff --git a/Libraries/Image/React-RCTImage.podspec b/Libraries/Image/React-RCTImage.podspec index 614245a225300d..283f0994d5a36c 100644 --- a/Libraries/Image/React-RCTImage.podspec +++ b/Libraries/Image/React-RCTImage.podspec @@ -44,6 +44,7 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTImageHeaders", version s.dependency "React-RCTNetwork", version end diff --git a/Libraries/LinkingIOS/React-RCTLinking.podspec b/Libraries/LinkingIOS/React-RCTLinking.podspec index 1def01915d53d2..d81a27204a1b12 100644 --- a/Libraries/LinkingIOS/React-RCTLinking.podspec +++ b/Libraries/LinkingIOS/React-RCTLinking.podspec @@ -43,4 +43,5 @@ Pod::Spec.new do |s| s.dependency "React-Core/RCTLinkingHeaders", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/Libraries/NativeAnimation/React-RCTAnimation.podspec b/Libraries/NativeAnimation/React-RCTAnimation.podspec index 2a15aed44359b7..b8122e7844b1c6 100644 --- a/Libraries/NativeAnimation/React-RCTAnimation.podspec +++ b/Libraries/NativeAnimation/React-RCTAnimation.podspec @@ -43,5 +43,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTAnimationHeaders", version end diff --git a/Libraries/Network/React-RCTNetwork.podspec b/Libraries/Network/React-RCTNetwork.podspec index c0bd78a8cfb8e3..b1618e3c487788 100644 --- a/Libraries/Network/React-RCTNetwork.podspec +++ b/Libraries/Network/React-RCTNetwork.podspec @@ -44,5 +44,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTNetworkHeaders", version end diff --git a/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec b/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec index 4d410d7fdc5176..01f9a21b8bce8d 100644 --- a/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec +++ b/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec @@ -45,4 +45,5 @@ Pod::Spec.new do |s| s.dependency "React-Core/RCTPushNotificationHeaders", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/Libraries/Settings/React-RCTSettings.podspec b/Libraries/Settings/React-RCTSettings.podspec index 11770ad527e999..bc5f3bd3ff8456 100644 --- a/Libraries/Settings/React-RCTSettings.podspec +++ b/Libraries/Settings/React-RCTSettings.podspec @@ -44,5 +44,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTSettingsHeaders", version end diff --git a/Libraries/Vibration/React-RCTVibration.podspec b/Libraries/Vibration/React-RCTVibration.podspec index 28dcce4487b89a..577d03e4ad7465 100644 --- a/Libraries/Vibration/React-RCTVibration.podspec +++ b/Libraries/Vibration/React-RCTVibration.podspec @@ -44,5 +44,6 @@ Pod::Spec.new do |s| s.dependency "React-Codegen", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-Core/RCTVibrationHeaders", version end diff --git a/React-Core.podspec b/React-Core.podspec index 229846ec38751d..5f8304882b6790 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -95,6 +95,7 @@ Pod::Spec.new do |s| s.dependency "React-cxxreact", version s.dependency "React-perflogger", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-jsiexecutor", version s.dependency "Yoga" s.dependency "glog" diff --git a/React/CoreModules/React-CoreModules.podspec b/React/CoreModules/React-CoreModules.podspec index a4a605aaf01257..e4b5a32085426f 100644 --- a/React/CoreModules/React-CoreModules.podspec +++ b/React/CoreModules/React-CoreModules.podspec @@ -44,4 +44,5 @@ Pod::Spec.new do |s| s.dependency "React-RCTImage", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/React/FBReactNativeSpec/FBReactNativeSpec.podspec b/React/FBReactNativeSpec/FBReactNativeSpec.podspec index 37f2a17d8dffb5..26a2aafcab63c3 100644 --- a/React/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/React/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -47,6 +47,7 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "React-Core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "ReactCommon/turbomodule/core", version use_react_native_codegen!(s, { diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec index c28eee60d06fbe..e89485ac991abd 100644 --- a/ReactCommon/React-Fabric.podspec +++ b/ReactCommon/React-Fabric.podspec @@ -42,6 +42,7 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.subspec "animations" do |ss| ss.dependency folly_dep_name, folly_version diff --git a/ReactCommon/React-bridging.podspec b/ReactCommon/React-bridging.podspec index 660d0efdd9deb5..13d9bec09ffcfb 100644 --- a/ReactCommon/React-bridging.podspec +++ b/ReactCommon/React-bridging.podspec @@ -40,4 +40,5 @@ Pod::Spec.new do |s| s.dependency "RCT-Folly", folly_version s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/ReactCommon/ReactCommon.podspec b/ReactCommon/ReactCommon.podspec index 4cd4f04e59c31a..538fc077f62004 100644 --- a/ReactCommon/ReactCommon.podspec +++ b/ReactCommon/ReactCommon.podspec @@ -46,6 +46,7 @@ Pod::Spec.new do |s| ss.dependency "React-Core", version ss.dependency "React-cxxreact", version ss.dependency "React-jsi", version + ss.dependency "React-jsc", version ss.dependency "RCT-Folly", folly_version s.dependency "React-logger", version ss.dependency "DoubleConversion" diff --git a/ReactCommon/cxxreact/React-cxxreact.podspec b/ReactCommon/cxxreact/React-cxxreact.podspec index c4498e9d3f1f80..d54906d0e1e512 100644 --- a/ReactCommon/cxxreact/React-cxxreact.podspec +++ b/ReactCommon/cxxreact/React-cxxreact.podspec @@ -45,5 +45,6 @@ Pod::Spec.new do |s| s.dependency "React-runtimeexecutor", version s.dependency "React-perflogger", version s.dependency "React-jsi", version + s.dependency "React-jsc", version s.dependency "React-logger", version end diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec index 83d64d3a81978f..51d717b2655135 100644 --- a/ReactCommon/hermes/React-hermes.podspec +++ b/ReactCommon/hermes/React-hermes.podspec @@ -27,7 +27,7 @@ boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| s.name = "React-hermes" s.version = version - s.summary = "-" # TODO + s.summary = "Hermes engine for React Native" s.homepage = "https://reactnative.dev/" s.license = package['license'] s.author = "Facebook, Inc. and its affiliates" diff --git a/ReactCommon/jsi/React-jsc.podspec b/ReactCommon/jsi/React-jsc.podspec new file mode 100644 index 00000000000000..ed6e923bfae6c7 --- /dev/null +++ b/ReactCommon/jsi/React-jsc.podspec @@ -0,0 +1,42 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1") +else + source[:tag] = "v#{version}" +end + +Pod::Spec.new do |s| + s.name = "React-jsc" + s.version = version + s.summary = "JavaScriptCore engine for React Native" + s.homepage = "https://reactnative.dev/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "12.4" } + s.source = source + s.source_files = "JSCRuntime.{cpp,h}" + s.exclude_files = "**/test/*" + s.framework = "JavaScriptCore" + s.dependency "React-jsi", version + + s.default_subspec = "Default" + + s.subspec "Default" do + # no-op + end + + s.subspec "Fabric" do |ss| + ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" } + end +end diff --git a/ReactCommon/jsi/React-jsi.podspec b/ReactCommon/jsi/React-jsi.podspec index 8f0c3cdcaa32d4..96465cfa4d205e 100644 --- a/ReactCommon/jsi/React-jsi.podspec +++ b/ReactCommon/jsi/React-jsi.podspec @@ -16,41 +16,21 @@ else source[:tag] = "v#{version}" end -folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.07.22.00' -boost_compiler_flags = '-Wno-documentation' - Pod::Spec.new do |s| s.name = "React-jsi" s.version = version - s.summary = "-" # TODO + s.summary = "JavaScript Interface layer for React Native" s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "12.4" } s.source = source - s.source_files = "**/*.{cpp,h}" + s.source_files = "jsi/*.{cpp,h}" s.exclude_files = [ "jsi/JSIDynamic.{h,cpp}", - "jsi/jsilib-*.{h,cpp}", + "jsi/jsilib-posix.cpp", + "jsi/jsilib-windows.cpp", "**/test/*" ] - s.framework = "JavaScriptCore" - s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags - s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"" } s.header_dir = "jsi" - s.default_subspec = "Default" - - s.dependency "boost", "1.76.0" - s.dependency "DoubleConversion" - s.dependency "RCT-Folly", folly_version - s.dependency "glog" - - s.subspec "Default" do - # no-op - end - - s.subspec "Fabric" do |ss| - ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" } - end end diff --git a/ReactCommon/jsi/React-jsidynamic.podspec b/ReactCommon/jsi/React-jsidynamic.podspec index 831c6b010fc461..7e43baacfc7a6e 100644 --- a/ReactCommon/jsi/React-jsidynamic.podspec +++ b/ReactCommon/jsi/React-jsidynamic.podspec @@ -39,4 +39,5 @@ Pod::Spec.new do |s| s.dependency "RCT-Folly", folly_version s.dependency "glog" s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec index 5cbadf30d531fe..09781b7d5a7e09 100644 --- a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec +++ b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec @@ -33,4 +33,5 @@ Pod::Spec.new do |s| s.header_dir = "ReactCommon" s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/packages/rn-tester/RCTTest/React-RCTTest.podspec b/packages/rn-tester/RCTTest/React-RCTTest.podspec index f6836ca2fa1e2d..377754901b2cbf 100644 --- a/packages/rn-tester/RCTTest/React-RCTTest.podspec +++ b/packages/rn-tester/RCTTest/React-RCTTest.podspec @@ -44,4 +44,5 @@ Pod::Spec.new do |s| s.dependency "React-CoreModules", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version + s.dependency "React-jsc", version end diff --git a/scripts/cocoapods/__tests__/codegen_utils-test.rb b/scripts/cocoapods/__tests__/codegen_utils-test.rb index 258875ebf9a650..606020bd9b0e7b 100644 --- a/scripts/cocoapods/__tests__/codegen_utils-test.rb +++ b/scripts/cocoapods/__tests__/codegen_utils-test.rb @@ -463,6 +463,7 @@ def get_podspec_no_fabric_no_script "RCTTypeSafety": ["99.98.97"], "React-Core": ["99.98.97"], "React-jsi": ["99.98.97"], + "React-jsc": ["99.98.97"], "ReactCommon/turbomodule/core": ["99.98.97"] } } diff --git a/scripts/cocoapods/__tests__/fabric-test.rb b/scripts/cocoapods/__tests__/fabric-test.rb index 0cb0a6316161cb..5076c70e7085b1 100644 --- a/scripts/cocoapods/__tests__/fabric-test.rb +++ b/scripts/cocoapods/__tests__/fabric-test.rb @@ -5,6 +5,7 @@ require "test/unit" require_relative "../fabric.rb" +require_relative "../utils.rb" require_relative "./test_utils/podSpy.rb" class FabricTest < Test::Unit::TestCase @@ -13,6 +14,13 @@ def setup podSpy_cleanUp() end + def teardown + podSpy_cleanUp() + end + + # ================== # + # TEST - setupFabric # + # ================== # def test_setupFabric_installsPods # Arrange prefix = "../.." @@ -30,7 +38,7 @@ def check_installed_pods(prefix) check_pod("React-Fabric", :path => "#{prefix}/ReactCommon") check_pod("React-rncore", :path => "#{prefix}/ReactCommon") check_pod("React-graphics", :path => "#{prefix}/ReactCommon/react/renderer/graphics") - check_pod("React-jsi/Fabric", :path => "#{prefix}/ReactCommon/jsi") + check_pod("React-jsc/Fabric", :path => "#{prefix}/ReactCommon/jsi") check_pod("React-RCTFabric", :path => "#{prefix}/React", :modular_headers => true) check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec") end @@ -45,5 +53,4 @@ def check_pod(name, path: nil, modular_headers: nil, podspec: nil) assert_equal(params, expected_params) end - end diff --git a/scripts/cocoapods/codegen_utils.rb b/scripts/cocoapods/codegen_utils.rb index 1d2e89bcc55197..c1548f90bfdeb4 100644 --- a/scripts/cocoapods/codegen_utils.rb +++ b/scripts/cocoapods/codegen_utils.rb @@ -104,6 +104,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa "RCTTypeSafety": [version], "React-Core": [version], "React-jsi": [version], + "React-jsc": [version], "ReactCommon/turbomodule/core": [version] } } diff --git a/scripts/cocoapods/fabric.rb b/scripts/cocoapods/fabric.rb index c27bf7975ed84c..bcdb2960df58e8 100644 --- a/scripts/cocoapods/fabric.rb +++ b/scripts/cocoapods/fabric.rb @@ -4,16 +4,14 @@ # LICENSE file in the root directory of this source tree. -# It sets up the faric dependencies. +# It sets up the Fabric dependencies. # -# @parameter prefix: prefix to use to reach react-native -# @parameter new_arch_enabled: whether the new arch is enabled or not -# @parameter codegen_output_dir: the directory where the code is generated -def setup_fabric!(prefix) - pod 'React-Fabric', :path => "#{prefix}/ReactCommon" - pod 'React-rncore', :path => "#{prefix}/ReactCommon" - pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics" - pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi" - pod 'React-RCTFabric', :path => "#{prefix}/React", :modular_headers => true - pod 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec" +# @parameter react_native_path: relative path to react-native +def setup_fabric!(react_native_path) + pod 'React-Fabric', :path => "#{react_native_path}/ReactCommon" + pod 'React-rncore', :path => "#{react_native_path}/ReactCommon" + pod 'React-graphics', :path => "#{react_native_path}/ReactCommon/react/renderer/graphics" + pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi" + pod 'React-RCTFabric', :path => "#{react_native_path}/React", :modular_headers => true + pod 'RCT-Folly/Fabric', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec" end diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 3363dfced09df1..3157a42e0bec62 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -95,6 +95,7 @@ def use_react_native! ( pod 'React-bridging', :path => "#{prefix}/ReactCommon" pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact" pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi" + pod 'React-jsc', :path => "#{prefix}/ReactCommon/jsi" pod 'React-jsidynamic', :path => "#{prefix}/ReactCommon/jsi" pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor" pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector" From d5be4a546d20779525fb0716aee89f8c0ae9a3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 20 Oct 2022 06:55:10 -0700 Subject: [PATCH 2/4] CocoaPods: Do not configure Hermes search paths if Hermes is disabled Summary: The React-Hermes and hermes-engine headers are only needed when Hermes is enabled. Changelog: [internal] Differential Revision: D40451162 fbshipit-source-id: bdebd418aeb36254fbaabfa460dacf86e7cb1f3a --- .../AppDelegate/React-RCTAppDelegate.podspec | 18 +++++++++++- React-Core.podspec | 28 +++++++++++++++---- scripts/react_native_pods.rb | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/Libraries/AppDelegate/React-RCTAppDelegate.podspec index 98dd9428135378..fff87118479cc6 100644 --- a/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -23,6 +23,22 @@ new_arch_enabled_flag="RCT_NEW_ARCH_ENABLED" is_new_arch_enabled = ENV[new_arch_enabled_flag] == "1" other_cflags = "$(inherited) -DRN_FABRIC_ENABLED " + folly_flags + (is_new_arch_enabled ? " -D"+"RCT_NEW_ARCH_ENABLED" : "") +use_hermes = ENV['USE_HERMES'] == '1' + +header_search_paths = [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/RCT-Folly", + "${PODS_ROOT}/Headers/Public/FlipperKit", + "$(PODS_ROOT)/Headers/Public/ReactCommon", + "$(PODS_ROOT)/Headers/Public/React-RCTFabric" +].concat(use_hermes ? [ + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" +] : []).map{|p| "\"#{p}\""}.join(" ") + Pod::Spec.new do |s| s.name = "React-RCTAppDelegate" s.version = version @@ -38,7 +54,7 @@ Pod::Spec.new do |s| # This guard prevent to install the dependencies when we run `pod install` in the old architecture. s.compiler_flags = other_cflags s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", + "HEADER_SEARCH_PATHS" => header_search_paths, "OTHER_CPLUSPLUSFLAGS" => other_cflags, "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } diff --git a/React-Core.podspec b/React-Core.podspec index 5f8304882b6790..6997029a839b2e 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -20,6 +20,8 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' +use_hermes = ENV['USE_HERMES'] == '1' + header_subspecs = { 'CoreModulesHeaders' => 'React/CoreModules/**/*.h', 'RCTActionSheetHeaders' => 'Libraries/ActionSheetIOS/*.h', @@ -34,6 +36,19 @@ header_subspecs = { 'RCTVibrationHeaders' => 'Libraries/Vibration/*.h', } +header_search_paths = [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/RCT-Folly", + "${PODS_ROOT}/Headers/Public/FlipperKit", + "$(PODS_ROOT)/Headers/Public/ReactCommon", + "$(PODS_ROOT)/Headers/Public/React-RCTFabric" +].concat(use_hermes ? [ + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" +] : []).map{|p| "\"#{p}\""}.join(" ") + Pod::Spec.new do |s| s.name = "React-Core" s.version = version @@ -48,12 +63,13 @@ Pod::Spec.new do |s| s.header_dir = "React" s.framework = "JavaScriptCore" s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", - "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"", - "DEFINES_MODULE" => "YES", - "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", - } + "HEADER_SEARCH_PATHS" => header_search_paths, + "DEFINES_MODULE" => "YES", + "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", + }.merge!(use_hermes ? { + "FRAMEWORK_SEARCH_PATHS" => "\"$(PODS_CONFIGURATION_BUILD_DIR)/React-hermes\"" + } : {}) s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""} s.default_subspec = "Default" diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 3157a42e0bec62..983e7c5763d89b 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -67,6 +67,7 @@ def use_react_native! ( # Better to rely and enable this environment flag if the new architecture is turned on using flags. ENV['RCT_NEW_ARCH_ENABLED'] = new_arch_enabled ? "1" : "0" fabric_enabled = fabric_enabled || new_arch_enabled + ENV['USE_HERMES'] = hermes_enabled ? "1" : "0" prefix = path From c12558a2e0b9e9196e768f8d7f489b32d9e57044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 20 Oct 2022 06:55:10 -0700 Subject: [PATCH 3/4] CocoaPods: Consolidate JS Engine configuration in jsengine.rb Summary: Move JSC and Hermes CocoaPods configuration to scripts/cocoapods/jsengine.rb. This file provides a setup_jsc function and a setup_hermes function. Changelog: [internal] Differential Revision: D40459234 fbshipit-source-id: bd76472ef604ec6b930d7e353eba61f7a962103d --- scripts/cocoapods/__tests__/fabric-test.rb | 5 +- scripts/cocoapods/__tests__/hermes-test.rb | 86 ------------- scripts/cocoapods/__tests__/jsengine-test.rb | 124 +++++++++++++++++++ scripts/cocoapods/fabric.rb | 3 +- scripts/cocoapods/hermes.rb | 20 --- scripts/cocoapods/jsengine.rb | 40 ++++++ scripts/react_native_pods.rb | 15 ++- 7 files changed, 176 insertions(+), 117 deletions(-) delete mode 100644 scripts/cocoapods/__tests__/hermes-test.rb create mode 100644 scripts/cocoapods/__tests__/jsengine-test.rb delete mode 100644 scripts/cocoapods/hermes.rb create mode 100644 scripts/cocoapods/jsengine.rb diff --git a/scripts/cocoapods/__tests__/fabric-test.rb b/scripts/cocoapods/__tests__/fabric-test.rb index 5076c70e7085b1..9ded6bd22028e7 100644 --- a/scripts/cocoapods/__tests__/fabric-test.rb +++ b/scripts/cocoapods/__tests__/fabric-test.rb @@ -26,19 +26,18 @@ def test_setupFabric_installsPods prefix = "../.." # Act - setup_fabric!(prefix) + setup_fabric!(:react_native_path => prefix) # Assert check_installed_pods(prefix) end def check_installed_pods(prefix) - assert_equal($podInvocationCount, 6) + assert_equal($podInvocationCount, 5) check_pod("React-Fabric", :path => "#{prefix}/ReactCommon") check_pod("React-rncore", :path => "#{prefix}/ReactCommon") check_pod("React-graphics", :path => "#{prefix}/ReactCommon/react/renderer/graphics") - check_pod("React-jsc/Fabric", :path => "#{prefix}/ReactCommon/jsi") check_pod("React-RCTFabric", :path => "#{prefix}/React", :modular_headers => true) check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec") end diff --git a/scripts/cocoapods/__tests__/hermes-test.rb b/scripts/cocoapods/__tests__/hermes-test.rb deleted file mode 100644 index 64562ec5d22d7d..00000000000000 --- a/scripts/cocoapods/__tests__/hermes-test.rb +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -require "test/unit" -require_relative "../hermes.rb" -require_relative "./test_utils/podSpy.rb" -require_relative "./test_utils/PodMock.rb" -require_relative "./test_utils/Open3Mock.rb" - -class HermesTests < Test::Unit::TestCase - - :prefix - - def setup - @prefix = "../.." - end - - def teardown - Open3.reset() - Pod::Config.reset() - Pod::UI.reset() - podSpy_cleanUp() - end - - # ============================= # - # TEST - installHermesIfEnabled # - # ============================= # - def test_installHermesIfEnabled_whenHermesIsDisabled_doesNothing - # Arrange - - # Act - install_hermes_if_enabled(false, @prefix) - - # Assert - assert_equal($podInvocationCount, 0) - assert_equal($podInvocation, {}) - assert_equal(Pod::UI.collected_infoes, []) - assert_equal(Open3.collected_commands, []) - assert_equal(Open3.collected_dirs, []) - end - - def test_installHermesIfEnabled_whenHermesIsEnabledAndHermesScriptFails_abort - # Arrange - Pod::Config.instance.installation_root.set_installation_root("Pods/") - Open3.set_returned_status(1) - Open3.set_returned_text("This test\nshould fail") - - # Act - assert_raises { - install_hermes_if_enabled(true, @prefix) - } - - # Assert - assert_equal(Open3.collected_commands, ["node scripts/hermes/prepare-hermes-for-build"]) - assert_equal(Open3.collected_dirs, ["Pods/../.."]) - assert_equal(Pod::UI.collected_infoes, ["This test", "should fail"]) - assert_equal($podInvocationCount, 0) - assert_equal($podInvocation, {}) - end - - def test_installHermesIfEnabled_whenHermesIsEnabledAndHermesScriptSucceeds_installsPods - # Arrange - Pod::Config.instance.installation_root.set_installation_root("Pods/") - Open3.set_returned_status(0) - Open3.set_returned_text("This is\nthe text\nreturned by\nprepare-hermes-for-build") - - # Act - install_hermes_if_enabled(true, @prefix) - - # Assert - assert_equal(Open3.collected_commands, ["node scripts/hermes/prepare-hermes-for-build"]) - assert_equal(Open3.collected_dirs, ["Pods/../.."]) - assert_equal(Pod::UI.collected_infoes, [ - "This is", - "the text", - "returned by", - "prepare-hermes-for-build", - ]) - assert_equal($podInvocationCount, 3) - assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes") - assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") - assert_equal($podInvocation["hermes-engine"][:podspec], "../../sdks/hermes/hermes-engine.podspec") - end -end diff --git a/scripts/cocoapods/__tests__/jsengine-test.rb b/scripts/cocoapods/__tests__/jsengine-test.rb new file mode 100644 index 00000000000000..51efcef5da565d --- /dev/null +++ b/scripts/cocoapods/__tests__/jsengine-test.rb @@ -0,0 +1,124 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "test/unit" +require_relative "../jsengine.rb" +require_relative "./test_utils/podSpy.rb" +require_relative "./test_utils/PodMock.rb" +require_relative "./test_utils/Open3Mock.rb" + +class JSEngineTests < Test::Unit::TestCase + + :react_native_path + + def setup + @react_native_path = "../.." + podSpy_cleanUp() + end + + def teardown + Open3.reset() + Pod::Config.reset() + Pod::UI.reset() + podSpy_cleanUp() + ENV['USE_HERMES'] = '1' + end + + # =============== # + # TEST - setupJsc # + # =============== # + def test_setupJsc_installsPods + # Arrange + fabric_enabled = false + + # Act + setup_jsc!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) + + # Assert + assert_equal($podInvocationCount, 2) + assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi") + end + + def test_setupJsc_installsPods_installsFabricSubspecWhenFabricEnabled + # Arrange + fabric_enabled = true + + # Act + setup_jsc!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) + + # Assert + assert_equal($podInvocationCount, 3) + assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-jsc/Fabric"][:path], "../../ReactCommon/jsi") + end + + # ================== # + # TEST - setupHermes # + # ================== # + def test_setupHermes_whenHermesScriptFails_abort + # Arrange + fabric_enabled = false + Pod::Config.instance.installation_root.set_installation_root("Pods/") + Open3.set_returned_status(1) + Open3.set_returned_text("This test\nshould fail") + + # Act + assert_raises { + setup_hermes!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) + } + + # Assert + assert_equal(Open3.collected_commands, ["node scripts/hermes/prepare-hermes-for-build"]) + assert_equal(Open3.collected_dirs, ["Pods/../.."]) + assert_equal(Pod::UI.collected_infoes, ["This test", "should fail"]) + assert_equal($podInvocationCount, 0) + assert_equal($podInvocation, {}) + end + + def test_setupHermes_whenHermesScriptSucceeds_installsPods + # Arrange + fabric_enabled = false + Pod::Config.instance.installation_root.set_installation_root("Pods/") + Open3.set_returned_status(0) + Open3.set_returned_text("This is\nthe text\nreturned by\nprepare-hermes-for-build") + + # Act + setup_hermes!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) + + # Assert + assert_equal(Open3.collected_commands, ["node scripts/hermes/prepare-hermes-for-build"]) + assert_equal(Open3.collected_dirs, ["Pods/../.."]) + assert_equal(Pod::UI.collected_infoes, [ + "This is", + "the text", + "returned by", + "prepare-hermes-for-build", + ]) + assert_equal($podInvocationCount, 5) + assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes") + assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") + assert_equal($podInvocation["hermes-engine"][:podspec], "../../sdks/hermes/hermes-engine.podspec") + end + + def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled + # Arrange + fabric_enabled = true + + # Act + setup_hermes!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) + + # Assert + assert_equal($podInvocationCount, 6) + assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["React-jsc/Fabric"][:path], "../../ReactCommon/jsi") + assert_equal($podInvocation["hermes-engine"][:podspec], "../../sdks/hermes/hermes-engine.podspec") + assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes") + assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") + end +end diff --git a/scripts/cocoapods/fabric.rb b/scripts/cocoapods/fabric.rb index bcdb2960df58e8..b694bb64d97210 100644 --- a/scripts/cocoapods/fabric.rb +++ b/scripts/cocoapods/fabric.rb @@ -7,11 +7,10 @@ # It sets up the Fabric dependencies. # # @parameter react_native_path: relative path to react-native -def setup_fabric!(react_native_path) +def setup_fabric!(react_native_path: "../node_modules/react-native") pod 'React-Fabric', :path => "#{react_native_path}/ReactCommon" pod 'React-rncore', :path => "#{react_native_path}/ReactCommon" pod 'React-graphics', :path => "#{react_native_path}/ReactCommon/react/renderer/graphics" - pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi" pod 'React-RCTFabric', :path => "#{react_native_path}/React", :modular_headers => true pod 'RCT-Folly/Fabric', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec" end diff --git a/scripts/cocoapods/hermes.rb b/scripts/cocoapods/hermes.rb deleted file mode 100644 index 747b744c87d7df..00000000000000 --- a/scripts/cocoapods/hermes.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -def install_hermes_if_enabled(hermes_enabled, react_native_path) - unless hermes_enabled - return - end - - prepare_hermes = 'node scripts/hermes/prepare-hermes-for-build' - react_native_dir = Pod::Config.instance.installation_root.join(react_native_path) - prep_output, prep_status = Open3.capture2e(prepare_hermes, :chdir => react_native_dir) - prep_output.split("\n").each { |line| Pod::UI.info line } - abort unless prep_status == 0 - - pod 'React-hermes', :path => "#{react_native_path}/ReactCommon/hermes" - pod 'libevent', '~> 2.1.12' - pod 'hermes-engine', :podspec => "#{react_native_path}/sdks/hermes/hermes-engine.podspec" -end diff --git a/scripts/cocoapods/jsengine.rb b/scripts/cocoapods/jsengine.rb new file mode 100644 index 00000000000000..a07ff842806c5d --- /dev/null +++ b/scripts/cocoapods/jsengine.rb @@ -0,0 +1,40 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require_relative './utils.rb' + +# It sets up the JavaScriptCore and JSI pods. +# +# @parameter react_native_path: relative path to react-native +# @parameter fabric_enabled: whether Fabirc is enabled +def setup_jsc!(react_native_path: "../node_modules/react-native", fabric_enabled: false) + pod 'React-jsi', :path => "#{react_native_path}/ReactCommon/jsi" + pod 'React-jsc', :path => "#{react_native_path}/ReactCommon/jsi" + if fabric_enabled + pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi" + end +end + +# It sets up the Hermes and JSI pods. +# +# @parameter react_native_path: relative path to react-native +# @parameter fabric_enabled: whether Fabirc is enabled +def setup_hermes!(react_native_path: "../node_modules/react-native", fabric_enabled: false) + # The following captures the output of prepare_hermes for use in tests + prepare_hermes = 'node scripts/hermes/prepare-hermes-for-build' + react_native_dir = Pod::Config.instance.installation_root.join(react_native_path) + prep_output, prep_status = Open3.capture2e(prepare_hermes, :chdir => react_native_dir) + prep_output.split("\n").each { |line| Pod::UI.info line } + abort unless prep_status == 0 + + pod 'React-jsi', :path => "#{react_native_path}/ReactCommon/jsi" + pod 'React-jsc', :path => "#{react_native_path}/ReactCommon/jsi" + if fabric_enabled + pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi" + end + pod 'hermes-engine', :podspec => "#{react_native_path}/sdks/hermes/hermes-engine.podspec" + pod 'React-hermes', :path => "#{react_native_path}/ReactCommon/hermes" + pod 'libevent', '~> 2.1.12' +end diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 983e7c5763d89b..995b6ca3e636e4 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -7,7 +7,7 @@ require 'open3' require 'pathname' require_relative './react_native_pods_utils/script_phases.rb' -require_relative './cocoapods/hermes.rb' +require_relative './cocoapods/jsengine.rb' require_relative './cocoapods/flipper.rb' require_relative './cocoapods/fabric.rb' require_relative './cocoapods/codegen.rb' @@ -95,11 +95,16 @@ def use_react_native! ( pod 'React-bridging', :path => "#{prefix}/ReactCommon" pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact" - pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi" - pod 'React-jsc', :path => "#{prefix}/ReactCommon/jsi" + + if hermes_enabled + setup_hermes!(:react_native_path => prefix, :fabric_enabled => fabric_enabled) + else + setup_jsc!(:react_native_path => prefix, :fabric_enabled => fabric_enabled) + end pod 'React-jsidynamic', :path => "#{prefix}/ReactCommon/jsi" pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor" pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector" + pod 'React-callinvoker', :path => "#{prefix}/ReactCommon/callinvoker" pod 'React-runtimeexecutor', :path => "#{prefix}/ReactCommon/runtimeexecutor" pod 'React-perflogger', :path => "#{prefix}/ReactCommon/reactperflogger" @@ -128,11 +133,9 @@ def use_react_native! ( if fabric_enabled checkAndGenerateEmptyThirdPartyProvider!(prefix, new_arch_enabled, $CODEGEN_OUTPUT_DIR) - setup_fabric!(prefix) + setup_fabric!(:react_native_path => prefix) end - install_hermes_if_enabled(hermes_enabled, prefix) - # CocoaPods `configurations` option ensures that the target is copied only for the specified configurations, # but those dependencies are still built. # Flipper doesn't currently compile for release https://github.com/facebook/react-native/issues/33764 From a5f3728e8dfad2634df187fa0c52b95344f25384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 20 Oct 2022 06:55:35 -0700 Subject: [PATCH 4/4] Do not build JSI in React-jsi when Hermes is enabled, resolve JSI ODR violation Summary: React-jsi provides JSI to allow React Native to interface with JavaScriptCore. The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI. This second copy of JSI would lead to an [ODR Violation](https://en.cppreference.com/w/cpp/language/definition). To resolve this, when Hermes is enabled: - React-hermes and hermes-engine are installed. - React-jsc is not installed. - React-jsi continues to be installed. - React-jsi will not build JSI. - React-jsi will declare a dependency on hermes-engine. The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project. When Hermes is disabled: - React-jsi and React-jsc are installed. - React-hermes and hermes-engine are not installed. - React-jsi will build JSI. Changelog: [iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled Reviewed By: cipolleschi Differential Revision: D40334913 fbshipit-source-id: c108f258dfe9eefb5b755bc38dc63eea9f3a02b3 --- Libraries/Blob/React-RCTBlob.podspec | 1 - Libraries/Image/React-RCTImage.podspec | 1 - Libraries/LinkingIOS/React-RCTLinking.podspec | 1 - .../React-RCTAnimation.podspec | 1 - Libraries/Network/React-RCTNetwork.podspec | 1 - .../React-RCTPushNotification.podspec | 1 - Libraries/Settings/React-RCTSettings.podspec | 1 - .../Vibration/React-RCTVibration.podspec | 1 - React-Core.podspec | 1 - React/CoreModules/React-CoreModules.podspec | 1 - .../FBReactNativeSpec.podspec | 1 - ReactCommon/React-Fabric.podspec | 1 - ReactCommon/React-bridging.podspec | 1 - ReactCommon/ReactCommon.podspec | 1 - ReactCommon/cxxreact/React-cxxreact.podspec | 1 - ReactCommon/hermes/React-hermes.podspec | 2 +- ReactCommon/jsi/React-jsc.podspec | 1 - ReactCommon/jsi/React-jsi.podspec | 27 +++++++++---- ReactCommon/jsi/React-jsidynamic.podspec | 1 - .../React-runtimeexecutor.podspec | 1 - .../rn-tester/RCTTest/React-RCTTest.podspec | 1 - .../cocoapods/__tests__/codegen_utils-test.rb | 40 ++++++++++--------- scripts/cocoapods/__tests__/jsengine-test.rb | 6 +-- .../__tests__/test_utils/CodegenUtilsMock.rb | 3 +- scripts/cocoapods/codegen.rb | 5 ++- scripts/cocoapods/codegen_utils.rb | 19 +++++++-- scripts/cocoapods/jsengine.rb | 4 -- scripts/react_native_pods.rb | 1 + sdks/hermes-engine/hermes-engine.podspec | 4 ++ 29 files changed, 70 insertions(+), 60 deletions(-) diff --git a/Libraries/Blob/React-RCTBlob.podspec b/Libraries/Blob/React-RCTBlob.podspec index a4606fe2f06ee6..30cf7e14171060 100644 --- a/Libraries/Blob/React-RCTBlob.podspec +++ b/Libraries/Blob/React-RCTBlob.podspec @@ -42,7 +42,6 @@ Pod::Spec.new do |s| s.dependency "React-Codegen", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTBlobHeaders", version s.dependency "React-Core/RCTWebSocket", version s.dependency "React-RCTNetwork", version diff --git a/Libraries/Image/React-RCTImage.podspec b/Libraries/Image/React-RCTImage.podspec index 283f0994d5a36c..614245a225300d 100644 --- a/Libraries/Image/React-RCTImage.podspec +++ b/Libraries/Image/React-RCTImage.podspec @@ -44,7 +44,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTImageHeaders", version s.dependency "React-RCTNetwork", version end diff --git a/Libraries/LinkingIOS/React-RCTLinking.podspec b/Libraries/LinkingIOS/React-RCTLinking.podspec index d81a27204a1b12..1def01915d53d2 100644 --- a/Libraries/LinkingIOS/React-RCTLinking.podspec +++ b/Libraries/LinkingIOS/React-RCTLinking.podspec @@ -43,5 +43,4 @@ Pod::Spec.new do |s| s.dependency "React-Core/RCTLinkingHeaders", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/Libraries/NativeAnimation/React-RCTAnimation.podspec b/Libraries/NativeAnimation/React-RCTAnimation.podspec index b8122e7844b1c6..2a15aed44359b7 100644 --- a/Libraries/NativeAnimation/React-RCTAnimation.podspec +++ b/Libraries/NativeAnimation/React-RCTAnimation.podspec @@ -43,6 +43,5 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTAnimationHeaders", version end diff --git a/Libraries/Network/React-RCTNetwork.podspec b/Libraries/Network/React-RCTNetwork.podspec index b1618e3c487788..c0bd78a8cfb8e3 100644 --- a/Libraries/Network/React-RCTNetwork.podspec +++ b/Libraries/Network/React-RCTNetwork.podspec @@ -44,6 +44,5 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTNetworkHeaders", version end diff --git a/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec b/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec index 01f9a21b8bce8d..4d410d7fdc5176 100644 --- a/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec +++ b/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec @@ -45,5 +45,4 @@ Pod::Spec.new do |s| s.dependency "React-Core/RCTPushNotificationHeaders", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/Libraries/Settings/React-RCTSettings.podspec b/Libraries/Settings/React-RCTSettings.podspec index bc5f3bd3ff8456..11770ad527e999 100644 --- a/Libraries/Settings/React-RCTSettings.podspec +++ b/Libraries/Settings/React-RCTSettings.podspec @@ -44,6 +44,5 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTSettingsHeaders", version end diff --git a/Libraries/Vibration/React-RCTVibration.podspec b/Libraries/Vibration/React-RCTVibration.podspec index 577d03e4ad7465..28dcce4487b89a 100644 --- a/Libraries/Vibration/React-RCTVibration.podspec +++ b/Libraries/Vibration/React-RCTVibration.podspec @@ -44,6 +44,5 @@ Pod::Spec.new do |s| s.dependency "React-Codegen", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-Core/RCTVibrationHeaders", version end diff --git a/React-Core.podspec b/React-Core.podspec index 6997029a839b2e..7be727f36705bc 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -111,7 +111,6 @@ Pod::Spec.new do |s| s.dependency "React-cxxreact", version s.dependency "React-perflogger", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-jsiexecutor", version s.dependency "Yoga" s.dependency "glog" diff --git a/React/CoreModules/React-CoreModules.podspec b/React/CoreModules/React-CoreModules.podspec index e4b5a32085426f..a4a605aaf01257 100644 --- a/React/CoreModules/React-CoreModules.podspec +++ b/React/CoreModules/React-CoreModules.podspec @@ -44,5 +44,4 @@ Pod::Spec.new do |s| s.dependency "React-RCTImage", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/React/FBReactNativeSpec/FBReactNativeSpec.podspec b/React/FBReactNativeSpec/FBReactNativeSpec.podspec index 26a2aafcab63c3..37f2a17d8dffb5 100644 --- a/React/FBReactNativeSpec/FBReactNativeSpec.podspec +++ b/React/FBReactNativeSpec/FBReactNativeSpec.podspec @@ -47,7 +47,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "React-Core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "ReactCommon/turbomodule/core", version use_react_native_codegen!(s, { diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec index e89485ac991abd..c28eee60d06fbe 100644 --- a/ReactCommon/React-Fabric.podspec +++ b/ReactCommon/React-Fabric.podspec @@ -42,7 +42,6 @@ Pod::Spec.new do |s| s.dependency "RCTTypeSafety", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.subspec "animations" do |ss| ss.dependency folly_dep_name, folly_version diff --git a/ReactCommon/React-bridging.podspec b/ReactCommon/React-bridging.podspec index 13d9bec09ffcfb..660d0efdd9deb5 100644 --- a/ReactCommon/React-bridging.podspec +++ b/ReactCommon/React-bridging.podspec @@ -40,5 +40,4 @@ Pod::Spec.new do |s| s.dependency "RCT-Folly", folly_version s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/ReactCommon/ReactCommon.podspec b/ReactCommon/ReactCommon.podspec index 538fc077f62004..4cd4f04e59c31a 100644 --- a/ReactCommon/ReactCommon.podspec +++ b/ReactCommon/ReactCommon.podspec @@ -46,7 +46,6 @@ Pod::Spec.new do |s| ss.dependency "React-Core", version ss.dependency "React-cxxreact", version ss.dependency "React-jsi", version - ss.dependency "React-jsc", version ss.dependency "RCT-Folly", folly_version s.dependency "React-logger", version ss.dependency "DoubleConversion" diff --git a/ReactCommon/cxxreact/React-cxxreact.podspec b/ReactCommon/cxxreact/React-cxxreact.podspec index d54906d0e1e512..c4498e9d3f1f80 100644 --- a/ReactCommon/cxxreact/React-cxxreact.podspec +++ b/ReactCommon/cxxreact/React-cxxreact.podspec @@ -45,6 +45,5 @@ Pod::Spec.new do |s| s.dependency "React-runtimeexecutor", version s.dependency "React-perflogger", version s.dependency "React-jsi", version - s.dependency "React-jsc", version s.dependency "React-logger", version end diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec index 51d717b2655135..0b6432596c828b 100644 --- a/ReactCommon/hermes/React-hermes.podspec +++ b/ReactCommon/hermes/React-hermes.podspec @@ -44,7 +44,7 @@ Pod::Spec.new do |s| }.merge!(build_type == :debug ? { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } : {}) s.header_dir = "reacthermes" s.dependency "React-cxxreact", version - s.dependency "React-jsi", version + s.dependency "React-jsidynamic", version s.dependency "React-jsiexecutor", version s.dependency "React-jsinspector", version s.dependency "React-perflogger", version diff --git a/ReactCommon/jsi/React-jsc.podspec b/ReactCommon/jsi/React-jsc.podspec index ed6e923bfae6c7..ce59f0e69e6ac9 100644 --- a/ReactCommon/jsi/React-jsc.podspec +++ b/ReactCommon/jsi/React-jsc.podspec @@ -29,7 +29,6 @@ Pod::Spec.new do |s| s.exclude_files = "**/test/*" s.framework = "JavaScriptCore" s.dependency "React-jsi", version - s.default_subspec = "Default" s.subspec "Default" do diff --git a/ReactCommon/jsi/React-jsi.podspec b/ReactCommon/jsi/React-jsi.podspec index 96465cfa4d205e..ac21bada4f44b2 100644 --- a/ReactCommon/jsi/React-jsi.podspec +++ b/ReactCommon/jsi/React-jsi.podspec @@ -5,6 +5,10 @@ require "json" +js_engine = ENV['USE_HERMES'] == "0" ? + :jsc : + :hermes + package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json"))) version = package['version'] @@ -25,12 +29,19 @@ Pod::Spec.new do |s| s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "12.4" } s.source = source - s.source_files = "jsi/*.{cpp,h}" - s.exclude_files = [ - "jsi/JSIDynamic.{h,cpp}", - "jsi/jsilib-posix.cpp", - "jsi/jsilib-windows.cpp", - "**/test/*" - ] - s.header_dir = "jsi" + + if js_engine == :jsc + s.source_files = "**/*.{cpp,h}" + s.exclude_files = [ + "jsi/JSIDynamic.{h,cpp}", + "jsi/jsilib-posix.cpp", + "jsi/jsilib-windows.cpp", + "**/test/*" + ] + s.header_dir = "jsi" + elsif js_engine == :hermes + # JSI is provided by hermes-engine when Hermes is enabled + s.source_files = "" + s.dependency "hermes-engine" + end end diff --git a/ReactCommon/jsi/React-jsidynamic.podspec b/ReactCommon/jsi/React-jsidynamic.podspec index 7e43baacfc7a6e..831c6b010fc461 100644 --- a/ReactCommon/jsi/React-jsidynamic.podspec +++ b/ReactCommon/jsi/React-jsidynamic.podspec @@ -39,5 +39,4 @@ Pod::Spec.new do |s| s.dependency "RCT-Folly", folly_version s.dependency "glog" s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec index 09781b7d5a7e09..5cbadf30d531fe 100644 --- a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec +++ b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec @@ -33,5 +33,4 @@ Pod::Spec.new do |s| s.header_dir = "ReactCommon" s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/packages/rn-tester/RCTTest/React-RCTTest.podspec b/packages/rn-tester/RCTTest/React-RCTTest.podspec index 377754901b2cbf..f6836ca2fa1e2d 100644 --- a/packages/rn-tester/RCTTest/React-RCTTest.podspec +++ b/packages/rn-tester/RCTTest/React-RCTTest.podspec @@ -44,5 +44,4 @@ Pod::Spec.new do |s| s.dependency "React-CoreModules", version s.dependency "ReactCommon/turbomodule/core", version s.dependency "React-jsi", version - s.dependency "React-jsc", version end diff --git a/scripts/cocoapods/__tests__/codegen_utils-test.rb b/scripts/cocoapods/__tests__/codegen_utils-test.rb index 606020bd9b0e7b..69a5f8c2dc0b35 100644 --- a/scripts/cocoapods/__tests__/codegen_utils-test.rb +++ b/scripts/cocoapods/__tests__/codegen_utils-test.rb @@ -39,9 +39,9 @@ def teardown Dir.reset() end - # ================================== # - # Test - GenerateReactCodegenPodspec # - # ================================== # + # ================================== # + # Test - GenerateReactCodegenPodspec # + # ================================== # def testGenerateReactCodegenPodspec_whenItHasBeenAlreadyGenerated_doesNothing # Arrange @@ -80,18 +80,19 @@ def testGenerateReactCodegenPodspec_whenItHasNotBeenAlreadyGenerated_generatesIt assert_true(CodegenUtils.react_codegen_podspec_generated) end - # ========================== # - # Test - GetReactCodegenSpec # - # ========================== # + # ========================== # + # Test - GetReactCodegenSpec # + # ========================== # def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspec - # Arrange + # Arrange File.files_to_read('package.json' => '{ "version": "99.98.97"}') - # Act + # Act podspec = CodegenUtils.new().get_react_codegen_spec( 'package.json', :fabric_enabled => false, + :hermes_enabled => true, :script_phases => nil ) @@ -101,13 +102,14 @@ def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspe end def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec - # Arrange + # Arrange File.files_to_read('package.json' => '{ "version": "99.98.97"}') # Act podspec = CodegenUtils.new().get_react_codegen_spec( 'package.json', :fabric_enabled => true, + :hermes_enabled => true, :script_phases => "echo Test Script Phase" ) @@ -117,11 +119,11 @@ def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec end # =============================== # - # Test - GetCodegenConfigFromFile # - # =============================== # + # Test - GetCodegenConfigFromFile # + # =============================== # def testGetCodegenConfigFromFile_whenFileDoesNotExists_returnEmpty - # Arrange + # Arrange # Act codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegenConfig') @@ -131,7 +133,7 @@ def testGetCodegenConfigFromFile_whenFileDoesNotExists_returnEmpty end def testGetCodegenConfigFromFile_whenFileExistsButHasNoKey_returnEmpty - # Arrange + # Arrange File.mocked_existing_files(['package.json']) File.files_to_read('package.json' => '{ "codegenConfig": {}}') @@ -143,7 +145,7 @@ def testGetCodegenConfigFromFile_whenFileExistsButHasNoKey_returnEmpty end def testGetCodegenConfigFromFile_whenFileExistsAndHasKey_returnObject - # Arrange + # Arrange File.mocked_existing_files(['package.json']) File.files_to_read('package.json' => '{ "codegenConfig": {"name": "MySpec"}}') @@ -217,7 +219,7 @@ def testGetListOfJSSpecs_whenDoesNotUsesLibraries_returnAListOfFiles # ================================== # # Test - GetReactCodegenScriptPhases # - # ================================== # + # ================================== # def testGetReactCodegenScriptPhases_whenAppPathNotDefined_abort # Arrange @@ -370,9 +372,9 @@ def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen ]) end - # ============================= # - # Test - CleanUpCodegenFolder # - # ============================= # + # ============================= # + # Test - CleanUpCodegenFolder # + # ============================= # def testCleanUpCodegenFolder_whenCleanupDone_doNothing # Arrange @@ -463,7 +465,7 @@ def get_podspec_no_fabric_no_script "RCTTypeSafety": ["99.98.97"], "React-Core": ["99.98.97"], "React-jsi": ["99.98.97"], - "React-jsc": ["99.98.97"], + "hermes-engine": ["99.98.97"], "ReactCommon/turbomodule/core": ["99.98.97"] } } diff --git a/scripts/cocoapods/__tests__/jsengine-test.rb b/scripts/cocoapods/__tests__/jsengine-test.rb index 51efcef5da565d..13ad540d5f25bf 100644 --- a/scripts/cocoapods/__tests__/jsengine-test.rb +++ b/scripts/cocoapods/__tests__/jsengine-test.rb @@ -98,7 +98,7 @@ def test_setupHermes_whenHermesScriptSucceeds_installsPods "returned by", "prepare-hermes-for-build", ]) - assert_equal($podInvocationCount, 5) + assert_equal($podInvocationCount, 4) assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes") assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") @@ -113,10 +113,8 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled setup_hermes!(:react_native_path => @react_native_path, :fabric_enabled => fabric_enabled) # Assert - assert_equal($podInvocationCount, 6) + assert_equal($podInvocationCount, 4) assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi") - assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi") - assert_equal($podInvocation["React-jsc/Fabric"][:path], "../../ReactCommon/jsi") assert_equal($podInvocation["hermes-engine"][:podspec], "../../sdks/hermes/hermes-engine.podspec") assert_equal($podInvocation["React-hermes"][:path], "../../ReactCommon/hermes") assert_equal($podInvocation["libevent"][:version], "~> 2.1.12") diff --git a/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb b/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb index 8d9750157e2e84..d5d3f5b73bb653 100644 --- a/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb +++ b/scripts/cocoapods/__tests__/test_utils/CodegenUtilsMock.rb @@ -66,7 +66,7 @@ def get_react_codegen_script_phases( return @react_codegen_script_phases end - def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fabric_enabled: false, script_phases: nil) + def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil) @get_react_codegen_spec_params.push({ package_json_file: package_json_file, folly_version: folly_version, @@ -88,6 +88,7 @@ def use_react_native_codegen_discovery!( app_path, react_native_path: "../node_modules/react-native", fabric_enabled: false, + hermes_enabled: true, config_file_dir: '', codegen_output_dir: 'build/generated/ios', config_key: 'codegenConfig', diff --git a/scripts/cocoapods/codegen.rb b/scripts/cocoapods/codegen.rb index fdf6a84bbbb985..f3c214de819360 100644 --- a/scripts/cocoapods/codegen.rb +++ b/scripts/cocoapods/codegen.rb @@ -73,6 +73,7 @@ def run_codegen!( disable_codegen: false, react_native_path: "../node_modules/react-native", fabric_enabled: false, + hermes_enabled: true, codegen_output_dir: 'build/generated/ios', config_key: 'codegenConfig', package_json_file: '~/app/package.json', @@ -86,6 +87,7 @@ def run_codegen!( app_path, :react_native_path => react_native_path, :fabric_enabled => fabric_enabled, + :hermes_enabled => hermes_enabled, :config_file_dir => config_file_dir, :codegen_output_dir => codegen_output_dir, :config_key => config_key, @@ -96,7 +98,8 @@ def run_codegen!( # This gets generated in use_react_native_codegen_discovery when codegen discovery is enabled. react_codegen_spec = codegen_utils.get_react_codegen_spec( package_json_file, - :fabric_enabled => fabric_enabled + :fabric_enabled => fabric_enabled, + :hermes_enabled => hermes_enabled ) codegen_utils.generate_react_codegen_podspec!(react_codegen_spec, codegen_output_dir) end diff --git a/scripts/cocoapods/codegen_utils.rb b/scripts/cocoapods/codegen_utils.rb index c1548f90bfdeb4..608d9f210cfd4d 100644 --- a/scripts/cocoapods/codegen_utils.rb +++ b/scripts/cocoapods/codegen_utils.rb @@ -65,8 +65,9 @@ def generate_react_codegen_podspec!(spec, codegen_output_dir) # Parameters # - package_json_file: the path to the `package.json`, required to extract the proper React Native version # - fabric_enabled: whether fabric is enabled or not. + # - hermes_enabled: whether hermes is enabled or not. # - script_phases: whether we want to add some build script phases or not. - def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fabric_enabled: false, script_phases: nil) + def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil) package = JSON.parse(File.read(package_json_file)) version = package['version'] @@ -104,7 +105,6 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa "RCTTypeSafety": [version], "React-Core": [version], "React-jsi": [version], - "React-jsc": [version], "ReactCommon/turbomodule/core": [version] } } @@ -116,6 +116,16 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa }); end + if hermes_enabled + spec[:'dependencies'].merge!({ + 'hermes-engine': [version], + }); + else + spec[:'dependencies'].merge!({ + 'React-jsc': [version], + }); + end + if script_phases Pod::UI.puts "[Codegen] Adding script_phases to React-Codegen." spec[:'script_phases'] = script_phases @@ -128,7 +138,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa # # Parameters # - config_path: a path to the configuration file - # - config_ket: the codegen configuration key + # - config_key: the codegen configuration key # # Returns: the list of dependencies as extracted from the package.json def get_codegen_config_from_file(config_path, config_key) @@ -182,6 +192,7 @@ def get_list_of_js_specs(app_codegen_config, app_path) def get_react_codegen_script_phases( app_path, fabric_enabled: false, + hermes_enabled: false, config_file_dir: '', react_native_path: "../node_modules/react-native", config_key: 'codegenConfig', @@ -230,6 +241,7 @@ def use_react_native_codegen_discovery!( app_path, react_native_path: "../node_modules/react-native", fabric_enabled: false, + hermes_enabled: true, config_file_dir: '', codegen_output_dir: 'build/generated/ios', config_key: 'codegenConfig', @@ -264,6 +276,7 @@ def use_react_native_codegen_discovery!( File.join(react_native_path, "package.json"), :folly_version => folly_version, :fabric_enabled => fabric_enabled, + :hermes_enabled => hermes_enabled, :script_phases => script_phases ) codegen_utils.generate_react_codegen_podspec!(react_codegen_spec, codegen_output_dir) diff --git a/scripts/cocoapods/jsengine.rb b/scripts/cocoapods/jsengine.rb index a07ff842806c5d..8ec69c59f0bafd 100644 --- a/scripts/cocoapods/jsengine.rb +++ b/scripts/cocoapods/jsengine.rb @@ -30,10 +30,6 @@ def setup_hermes!(react_native_path: "../node_modules/react-native", fabric_enab abort unless prep_status == 0 pod 'React-jsi', :path => "#{react_native_path}/ReactCommon/jsi" - pod 'React-jsc', :path => "#{react_native_path}/ReactCommon/jsi" - if fabric_enabled - pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi" - end pod 'hermes-engine', :podspec => "#{react_native_path}/sdks/hermes/hermes-engine.podspec" pod 'React-hermes', :path => "#{react_native_path}/ReactCommon/hermes" pod 'libevent', '~> 2.1.12' diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 995b6ca3e636e4..73b44c12bab708 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -124,6 +124,7 @@ def use_react_native! ( :disable_codegen => ENV['DISABLE_CODEGEN'] == '1', :react_native_path => prefix, :fabric_enabled => fabric_enabled, + :hermes_enabled => hermes_enabled, :codegen_output_dir => $CODEGEN_OUTPUT_DIR, :package_json_file => File.join(__dir__, "..", "package.json"), :folly_version => $FOLLY_VERSION diff --git a/sdks/hermes-engine/hermes-engine.podspec b/sdks/hermes-engine/hermes-engine.podspec index fd108231491024..369b989392f9a4 100644 --- a/sdks/hermes-engine/hermes-engine.podspec +++ b/sdks/hermes-engine/hermes-engine.podspec @@ -53,6 +53,10 @@ Pod::Spec.new do |spec| spec.preserve_paths = ["destroot/bin/*"].concat(build_type == :debug ? ["**/*.{h,c,cpp}"] : []) spec.source_files = "destroot/include/**/*.h" + spec.exclude_files = [ + "destroot/include/jsi/jsi/JSIDynamic.{h,cpp}", + "destroot/include/jsi/jsi/jsilib-*.{h,cpp}", + ] spec.header_mappings_dir = "destroot/include" spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"