From 86c2818892c3c4de8ce220b1c3a296451c5a196a Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Jun 2022 02:56:42 -0700 Subject: [PATCH] Fix broken use_frameworks from React-bridging (#34011) Summary: `use_frameworks!` is broken again in react-native 0.69 because React-bridging. in the `use_frameworks!` mode, header structures are flattened, so `#include ` is not reachable to the header. to somehow workaround the issue without touch React-bridging imports, the pr do these things: - use `header_mappings_dir` to keep `react/bridging` header structure - because the header structure is not default framework header structure, explicitly `HEADER_SEARCH_PATHS` is necessary. - forward declare `CallbackWrapper` and use it internally in ReactCommon. so that we don't need to add `HEADER_SEARCH_PATHS` for React-bridging to every pods depending on `ReactCommon/turbomodule/core`, e.g. React-RCTSettings.podspec. [iOS] [Fixed] - Fix use_frameworks! for 0.69 Pull Request resolved: https://github.com/facebook/react-native/pull/34011 Test Plan: ```sh $ npx react-native init RN069 --version next $ yarn ios ``` Reviewed By: cortinico, cipolleschi Differential Revision: D37169699 Pulled By: dmitryrykun fbshipit-source-id: 309c55f1c611a2fc3902a83e8af814daaf2af6a0 (cherry picked from commit f97c6a5b498eec95e99a02c7842cb2ae160cd6cd) --- ReactCommon/{react/bridging => }/React-bridging.podspec | 7 ++++--- ReactCommon/ReactCommon.podspec | 2 +- .../react/nativemodule/core/platform/ios/RCTTurboModule.h | 2 +- .../core/platform/ios/RCTTurboModuleManager.mm | 1 + scripts/react_native_pods.rb | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) rename ReactCommon/{react/bridging => }/React-bridging.podspec (87%) diff --git a/ReactCommon/react/bridging/React-bridging.podspec b/ReactCommon/React-bridging.podspec similarity index 87% rename from ReactCommon/react/bridging/React-bridging.podspec rename to ReactCommon/React-bridging.podspec index 99906e6d3cc408..5255c135d03185 100644 --- a/ReactCommon/react/bridging/React-bridging.podspec +++ b/ReactCommon/React-bridging.podspec @@ -5,7 +5,7 @@ require "json" -package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json"))) +package = JSON.parse(File.read(File.join(__dir__, "..", "package.json"))) version = package['version'] source = { :git => 'https://github.com/facebook/react-native.git' } @@ -28,9 +28,10 @@ Pod::Spec.new do |s| s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "12.4" } s.source = source - s.source_files = "**/*.{cpp,h}" - s.exclude_files = "tests" + s.source_files = "react/bridging/**/*.{cpp,h}" + s.exclude_files = "react/bridging/tests" s.header_dir = "react/bridging" + s.header_mappings_dir = "." s.compiler_flags = folly_compiler_flags s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\"", "USE_HEADERMAP" => "YES", diff --git a/ReactCommon/ReactCommon.podspec b/ReactCommon/ReactCommon.podspec index 3ec232132e87c8..717ba54859840d 100644 --- a/ReactCommon/ReactCommon.podspec +++ b/ReactCommon/ReactCommon.podspec @@ -32,7 +32,7 @@ Pod::Spec.new do |s| s.source = source s.header_dir = "ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility 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\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Private/React-bridging\"", + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"", "USE_HEADERMAP" => "YES", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h index c143aceb5f325d..1d16b084213f57 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h @@ -16,7 +16,6 @@ #import #import #import -#import #import #import @@ -27,6 +26,7 @@ namespace facebook { namespace react { +class CallbackWrapper; class Instance; typedef std::weak_ptr ( diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 6dfc6cb249c8ff..e57439c7f88f16 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -27,6 +27,7 @@ #import #import #import +#import using namespace facebook; using namespace facebook::react; diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index fe4ef7ddb9deb9..7f6ebab8820075 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -65,7 +65,7 @@ def use_react_native! (options={}) pod 'React-Core/DevSupport', :path => "#{prefix}/" end - pod 'React-bridging', :path => "#{prefix}/ReactCommon/react/bridging" + pod 'React-bridging', :path => "#{prefix}/ReactCommon" pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact" pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi" pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor"