mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
TurboModules: Simplify React-bridging usage (#35212)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35212 A previous change - https://github.com/facebook/react-native/pull/34011 - already fixed basic usage of <react/bridging/.../ imports. However that change was only tailored towards the usage of: <react/bridging/CallbackWrapper.h> Any other header besides <react/bridging/CallbackWrapper.h> from <react/bridging/... can't be imported at this time in Xcode ... ... which is bad. For C++ TurboModules we need to be able to access *any* <react/bridging/...> header via the React-Codegen CocoaPod. Hence adding bridging now as a sub-spec to the ReactCommon CocoaPod Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D41057878 fbshipit-source-id: 83c117bc5252d84dd419cdb72f145f65547d23b2 # Conflicts: # scripts/cocoapods/__tests__/codegen_utils-test.rb
This commit is contained in:
committed by
Lorenzo Sciandra
parent
83c8163540
commit
7ef7d99f1c
@@ -1,43 +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 "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
|
||||
|
||||
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-gnu-zero-variadic-macro-arguments'
|
||||
folly_version = '2021.07.22.00'
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "React-bridging"
|
||||
s.version = version
|
||||
s.summary = "-" # TODO
|
||||
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 = "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",
|
||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
||||
"GCC_WARN_PEDANTIC" => "YES" }
|
||||
|
||||
s.dependency "RCT-Folly", folly_version
|
||||
s.dependency "React-jsi", version
|
||||
end
|
||||
@@ -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/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
|
||||
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
||||
"USE_HEADERMAP" => "YES",
|
||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
||||
"GCC_WARN_PEDANTIC" => "YES" }
|
||||
@@ -40,7 +40,6 @@ Pod::Spec.new do |s|
|
||||
# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."
|
||||
# Note: Update this only when ready to minimize breaking changes.
|
||||
s.subspec "turbomodule" do |ss|
|
||||
ss.dependency "React-bridging", version
|
||||
ss.dependency "React-callinvoker", version
|
||||
ss.dependency "React-perflogger", version
|
||||
ss.dependency "React-Core", version
|
||||
@@ -51,6 +50,14 @@ Pod::Spec.new do |s|
|
||||
ss.dependency "DoubleConversion"
|
||||
ss.dependency "glog"
|
||||
|
||||
ss.subspec "bridging" do |sss|
|
||||
sss.dependency "React-jsi", version
|
||||
sss.source_files = "react/bridging/**/*.{cpp,h}"
|
||||
sss.exclude_files = "react/bridging/tests"
|
||||
sss.header_dir = "react/bridging"
|
||||
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" }
|
||||
end
|
||||
|
||||
ss.subspec "core" do |sss|
|
||||
sss.source_files = "react/nativemodule/core/ReactCommon/**/*.{cpp,h}",
|
||||
"react/nativemodule/core/platform/ios/**/*.{mm,cpp,h}"
|
||||
|
||||
@@ -465,7 +465,8 @@ class CodegenUtilsTests < Test::Unit::TestCase
|
||||
"RCTTypeSafety": ["99.98.97"],
|
||||
"React-Core": ["99.98.97"],
|
||||
"React-jsi": ["99.98.97"],
|
||||
"hermes-engine": [],
|
||||
"hermes-engine": ["99.98.97"],
|
||||
"ReactCommon/turbomodule/bridging": ["99.98.97"],
|
||||
"ReactCommon/turbomodule/core": ["99.98.97"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ class NewArchitectureTests < Test::Unit::TestCase
|
||||
{ :dependency_name => "React-Codegen" },
|
||||
{ :dependency_name => "RCTRequired" },
|
||||
{ :dependency_name => "RCTTypeSafety" },
|
||||
{ :dependency_name => "ReactCommon/turbomodule/bridging" },
|
||||
{ :dependency_name => "ReactCommon/turbomodule/core" }
|
||||
])
|
||||
end
|
||||
|
||||
@@ -328,60 +328,6 @@ class UtilsTests < Test::Unit::TestCase
|
||||
assert_equal(pods_projects_mock.save_invocation_count, 1)
|
||||
end
|
||||
|
||||
# ============================================= #
|
||||
# Test - Fix React-bridging Header Search Paths #
|
||||
# ============================================= #
|
||||
|
||||
def test_fixReactBridgingHeaderSearchPaths_correctlySetsTheHeaderSearchPathsForAllTargets
|
||||
# Arrange
|
||||
first_target = prepare_target("FirstTarget")
|
||||
second_target = prepare_target("SecondTarget")
|
||||
third_target = TargetMock.new("ThirdTarget", [
|
||||
BuildConfigurationMock.new("Debug", {
|
||||
"HEADER_SEARCH_PATHS" => '$(inherited) "${PODS_ROOT}/Headers/Public" '
|
||||
}),
|
||||
BuildConfigurationMock.new("Release", {
|
||||
"HEADER_SEARCH_PATHS" => '$(inherited) "${PODS_ROOT}/Headers/Public" '
|
||||
}),
|
||||
], nil)
|
||||
|
||||
user_project_mock = UserProjectMock.new("a/path", [
|
||||
prepare_config("Debug"),
|
||||
prepare_config("Release"),
|
||||
],
|
||||
:native_targets => [
|
||||
first_target,
|
||||
second_target
|
||||
]
|
||||
)
|
||||
pods_projects_mock = PodsProjectMock.new([], {"hermes-engine" => {}}, :native_targets => [
|
||||
third_target
|
||||
])
|
||||
installer = InstallerMock.new(pods_projects_mock, [
|
||||
AggregatedProjectMock.new(user_project_mock)
|
||||
])
|
||||
|
||||
# Act
|
||||
ReactNativePodsUtils.fix_react_bridging_header_search_paths(installer)
|
||||
|
||||
# Assert
|
||||
first_target.build_configurations.each do |config|
|
||||
assert_equal(config.build_settings["HEADER_SEARCH_PATHS"].strip,
|
||||
'$(inherited) "$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" "$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"'
|
||||
)
|
||||
end
|
||||
second_target.build_configurations.each do |config|
|
||||
assert_equal(config.build_settings["HEADER_SEARCH_PATHS"].strip,
|
||||
'$(inherited) "$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" "$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"'
|
||||
)
|
||||
end
|
||||
third_target.build_configurations.each do |config|
|
||||
assert_equal(config.build_settings["HEADER_SEARCH_PATHS"].strip,
|
||||
'$(inherited) "${PODS_ROOT}/Headers/Public" "$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" "$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# ===================================== #
|
||||
# Test - Apply Xcode14 React-Core patch #
|
||||
# ===================================== #
|
||||
|
||||
@@ -98,13 +98,14 @@ class CodegenUtils
|
||||
].join(' ')
|
||||
},
|
||||
'dependencies': {
|
||||
"FBReactNativeSpec": [version],
|
||||
"React-jsiexecutor": [version],
|
||||
"FBReactNativeSpec": [version],
|
||||
"React-jsiexecutor": [version],
|
||||
"RCT-Folly": [folly_version],
|
||||
"RCTRequired": [version],
|
||||
"RCTTypeSafety": [version],
|
||||
"React-Core": [version],
|
||||
"React-jsi": [version],
|
||||
"ReactCommon/turbomodule/bridging": [version],
|
||||
"ReactCommon/turbomodule/core": [version]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ class NewArchitectureHelper
|
||||
|
||||
spec.dependency "RCTRequired"
|
||||
spec.dependency "RCTTypeSafety"
|
||||
spec.dependency "ReactCommon/turbomodule/bridging"
|
||||
spec.dependency "ReactCommon/turbomodule/core"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,18 +107,6 @@ class ReactNativePodsUtils
|
||||
end
|
||||
end
|
||||
|
||||
def self.fix_react_bridging_header_search_paths(installer)
|
||||
installer.target_installation_results.pod_target_installation_results
|
||||
.each do |pod_name, target_installation_result|
|
||||
target_installation_result.native_target.build_configurations.each do |config|
|
||||
# For third party modules who have React-bridging dependency to search correct headers
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.apply_mac_catalyst_patches(installer)
|
||||
# Fix bundle signing issues
|
||||
installer.pods_project.targets.each do |target|
|
||||
|
||||
@@ -93,7 +93,6 @@ def use_react_native! (
|
||||
pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration"
|
||||
pod 'React-Core/RCTWebSocket', :path => "#{prefix}/"
|
||||
|
||||
pod 'React-bridging', :path => "#{prefix}/ReactCommon"
|
||||
pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact"
|
||||
|
||||
if hermes_enabled
|
||||
@@ -211,7 +210,6 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
|
||||
|
||||
ReactNativePodsUtils.exclude_i386_architecture_while_using_hermes(installer)
|
||||
ReactNativePodsUtils.fix_library_search_paths(installer)
|
||||
ReactNativePodsUtils.fix_react_bridging_header_search_paths(installer)
|
||||
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
|
||||
|
||||
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
|
||||
|
||||
Reference in New Issue
Block a user