Skip to content

Commit

Permalink
Fix hermes executor not available when use_frameworks is enabled (#34222
Browse files Browse the repository at this point in the history
)

Summary:
When in `use_frameworks!` + `hermes_enabled` mode, the React podspecs have not dependency to the `React-hermes` podspec. the `HermesExecutorFactory.h` is not available [here](https://github.com/facebook/react-native/blob/1d997ce6d67242b9f667b01365c5e719c3d3f8d7/React/AppSetup/RCTAppSetupUtils.h#L15) and [here](https://github.com/facebook/react-native/blob/1d997ce6d67242b9f667b01365c5e719c3d3f8d7/React/CxxBridge/RCTCxxBridge.mm#L44). The app will fallback to JSCRuntime and crash in release build because the JSCRuntime cannot evaluate Hermes bundles.

The pr tries to add `React-hermes` to Framework Search Paths and make the `HermesExecutorFactory.h` reachable when in use_frameworks mode.

This pr should fix the problem mentioned in [0.70 release discussion](reactwg/react-native-releases#26 (reply in thread)).

## Changelog

[iOS] [Fixed] - Fix Hermes executor not available when `use_frameworks` is enabled

Pull Request resolved: #34222

Test Plan:
use patch-package to apply the change to a RN 0.69.1 project with the following test cases:

- old architecture + jsc
- new architecture + hermes
- old architecture + `use_frameworks! :linkage => :static` + hermes
- old architecture +`use_frameworks! :linkage => :static` + hermes + release build

Reviewed By: sammy-SC

Differential Revision: D38112717

Pulled By: cipolleschi

fbshipit-source-id: ee78527f4686400856ab9a055cf30b20900afc17
  • Loading branch information
Kudo authored and kelset committed Jul 27, 2022
1 parent e7461ee commit 70daa6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ Pod::Spec.new do |s|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
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\"", "DEFINES_MODULE" => "YES", "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }
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",
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
s.default_subspec = "Default"

Expand Down

1 comment on commit 70daa6e

@billnbell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried to cherry pick this into 0.69.5 but could not.

I think the only new thing is literally "FRAMEWORK_SEARCH_PATHS" => ""${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"",

Please sign in to comment.