From 940ee8ae0d2a87b01e8e67b11115a1b314806163 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 11 May 2026 12:55:12 -0700 Subject: [PATCH] Remove RCT_HERMES_V1_ENABLED from CocoaPods infrastructure (#56735) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56735 - Remove `RCT_HERMES_V1_ENABLED` environment variable from `react_native_pods.rb` - Simplify `jsengine.rb` to always use `.hermesversion` tag file - Remove conditional `HERMES_V1_ENABLED=1` preprocessor definition from `utils.rb` - Simplify `hermes-engine.podspec`: always read `HERMES_VERSION_NAME`, use V1 source files, remove legacy inspector subspecs - Simplify `hermes-utils.rb`: remove `hermes_v1_enabled()` function, always use `250829098.0.0-stable` branch, always use `.hermesversion` tag file ## Changelog: [iOS][Removed] - Remove the RCT_HERMES_V1_ENABLED from Cocoapods ## Test plan - [x] iOS: `bundle exec pod install` — success - [x] iOS: `xcodebuild` rn-tester on iPhone 16 Pro simulator — BUILD SUCCEEDED Reviewed By: cortinico Differential Revision: D104247277 fbshipit-source-id: ba61c29f3471c3894c3690ac80f83038f0436b70 --- .../scripts/cocoapods/jsengine.rb | 2 +- .../react-native/scripts/cocoapods/utils.rb | 11 ++++----- .../react-native/scripts/react_native_pods.rb | 8 +++---- .../sdks/hermes-engine/hermes-engine.podspec | 24 +------------------ .../sdks/hermes-engine/hermes-utils.rb | 18 +++----------- 5 files changed, 12 insertions(+), 51 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/jsengine.rb b/packages/react-native/scripts/cocoapods/jsengine.rb index a15c92897bb..e1b49ef221b 100644 --- a/packages/react-native/scripts/cocoapods/jsengine.rb +++ b/packages/react-native/scripts/cocoapods/jsengine.rb @@ -13,7 +13,7 @@ def setup_hermes!(react_native_path: "../node_modules/react-native") react_native_dir = Pod::Config.instance.installation_root.join(react_native_path) # This `:tag => hermestag` below is only to tell CocoaPods to update hermes-engine when React Native version changes. # We have custom logic to compute the source for hermes-engine. See sdks/hermes-engine/* - hermestag_file_name = ENV['RCT_HERMES_V1_ENABLED'] == "1" ? ".hermesv1version" : ".hermesversion" + hermestag_file_name = ".hermesv1version" hermestag_file = File.join(react_native_dir, "sdks", hermestag_file_name) hermestag = File.exist?(hermestag_file) ? File.read(hermestag_file).strip : '' pod 'hermes-engine', :podspec => "#{react_native_path}/sdks/hermes-engine/hermes-engine.podspec", :tag => hermestag diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index c31332b9e6c..7901e8135ab 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -45,13 +45,10 @@ class ReactNativePodsUtils end def self.set_gcc_preprocessor_definition_for_React_hermes(installer) - if ENV['RCT_HERMES_V1_ENABLED'] == "1" - self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1 HERMES_V1_ENABLED=1", "React-hermes", :debug) - self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1 HERMES_V1_ENABLED=1", "React-RuntimeHermes", :debug) - else - self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-hermes", :debug) - self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-RuntimeHermes", :debug) - end + # HERMES_V1_ENABLED=1 is set unconditionally to stay aligned with the Android/CMake build, + # where react-native-flags.cmake always defines HERMES_V1_ENABLED=1. + self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1 HERMES_V1_ENABLED=1", "React-hermes", :debug) + self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1 HERMES_V1_ENABLED=1", "React-RuntimeHermes", :debug) self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "hermes-engine", :debug) end diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index a32bb5b7b84..3944c19d1a4 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -95,13 +95,11 @@ def use_react_native! ( # excluding the legacy arch unless the user turns this flag off explicitly. ENV['RCT_REMOVE_LEGACY_ARCH'] = ENV['RCT_REMOVE_LEGACY_ARCH'] == '0' ? '0' : '1' - # Enable Hermes V1 by default. - # Users can still turn it off and use legacy hermes by setting the RCT_HERMES_V1_ENABLED - # environment variable to '0'. - ENV['RCT_HERMES_V1_ENABLED']= ENV['RCT_HERMES_V1_ENABLED'] == '0' ? '0' : '1' - ReactNativePodsUtils.check_minimum_required_xcode() + # Enable Hermes V1 by default. Keep the env var setup for backward compatibility. + ENV['RCT_HERMES_V1_ENABLED'] = '1' + # Current target definition is provided by Cocoapods and it refers to the target # that has invoked the `use_react_native!` function. ReactNativePodsUtils.detect_use_frameworks(current_target_definition) diff --git a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec index 360c9d266ab..f3af9cd0fb7 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec +++ b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec @@ -56,15 +56,7 @@ Pod::Spec.new do |spec| spec.subspec 'Pre-built' do |ss| ss.preserve_paths = ["destroot/bin/*"].concat(["**/*.{h,c,cpp}"]) - if ENV["RCT_HERMES_V1_ENABLED"] == "0" - ss.source_files = "destroot/include/hermes/**/*.h" - else - # Hermes v1 is shipping a jsi/hermes.h header which is imported by the hermes.h header - # and that file is not present in React Native's JSI - # (see https://github.com/facebook/react-native/tree/main/packages/react-native/ReactCommon/jsi/jsi/ where there is - # hermes-interface.h but not hermes.h) - ss.source_files = ["destroot/include/hermes/**/*.h", "destroot/include/jsi/hermes.h"] - end + ss.source_files = ["destroot/include/hermes/**/*.h", "destroot/include/jsi/hermes.h"] ss.header_mappings_dir = "destroot/include" ss.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework" ss.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework" @@ -127,20 +119,6 @@ Pod::Spec.new do |spec| ss.header_dir = 'hermes/Public' end - if ENV['RCT_HERMES_V1_ENABLED'] == "0" - spec.subspec 'inspector' do |ss| - ss.source_files = '' - ss.public_header_files = 'API/hermes/inspector/*.h' - ss.header_dir = 'hermes/inspector' - end - - spec.subspec 'inspector_chrome' do |ss| - ss.source_files = '' - ss.public_header_files = 'API/hermes/inspector/chrome/*.h' - ss.header_dir = 'hermes/inspector/chrome' - end - end - hermesc_path = "${PODS_ROOT}/hermes-engine/build_host_hermesc" if ENV.has_key?('HERMES_OVERRIDE_HERMESC_PATH') && File.exist?(ENV['HERMES_OVERRIDE_HERMESC_PATH']) then diff --git a/packages/react-native/sdks/hermes-engine/hermes-utils.rb b/packages/react-native/sdks/hermes-engine/hermes-utils.rb index 65e7e450b28..6038f0bb7cc 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-utils.rb +++ b/packages/react-native/sdks/hermes-engine/hermes-utils.rb @@ -85,10 +85,6 @@ def hermes_commit_envvar_defined() return ENV.has_key?('HERMES_COMMIT') end -def hermes_v1_enabled() - return ENV['RCT_HERMES_V1_ENABLED'] != "0" -end - def force_build_from_tag(react_native_path) return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && File.exist?(hermestag_file(react_native_path)) end @@ -175,16 +171,12 @@ end def podspec_source_build_from_github_tag(react_native_path) tag = File.read(hermestag_file(react_native_path)).strip - if hermes_v1_enabled() - hermes_log("Using tag defined in sdks/.hermesv1version: #{tag}") - else - hermes_log("Using tag defined in sdks/.hermesversion: #{tag}") - end + hermes_log("Using tag defined in sdks/.hermesv1version: #{tag}") return {:git => HERMES_GITHUB_URL, :tag => tag} end def podspec_source_build_from_github_main() - branch = hermes_v1_enabled() ? "250829098.0.0-stable" : "main" + branch = "250829098.0.0-stable" hermes_log("Using the latest commit from #{branch}.") return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} #{branch} | cut -f 1`.strip} end @@ -210,11 +202,7 @@ def artifacts_dir() end def hermestag_file(react_native_path) - if hermes_v1_enabled() - return File.join(react_native_path, "sdks", ".hermesv1version") - else - return File.join(react_native_path, "sdks", ".hermesversion") - end + return File.join(react_native_path, "sdks", ".hermesv1version") end def release_tarball_url(version, build_type)