Skip to content

Commit

Permalink
TurboModules: Simplify React-bridging usage (facebook#35212)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#35212

A previous change - facebook#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
  • Loading branch information
christophpurrer authored and OlimpiaZurek committed May 22, 2023
1 parent 378e3db commit ee1fb6f
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 115 deletions.
43 changes: 0 additions & 43 deletions ReactCommon/React-bridging.podspec

This file was deleted.

11 changes: 9 additions & 2 deletions ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ 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" }

# 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
Expand All @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions scripts/cocoapods/__tests__/codegen_utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def get_podspec_no_fabric_no_script
"React-Core": ["99.98.97"],
"React-jsi": ["99.98.97"],
"hermes-engine": ["99.98.97"],
"ReactCommon/turbomodule/bridging": ["99.98.97"],
"ReactCommon/turbomodule/core": ["99.98.97"]
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/cocoapods/__tests__/new_architecture-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def test_installModulesDependencies_whenNewArchEnabledAndNewArchAndNoSearchPaths
{ :dependency_name => "React-Codegen" },
{ :dependency_name => "RCTRequired" },
{ :dependency_name => "RCTTypeSafety" },
{ :dependency_name => "ReactCommon/turbomodule/bridging" },
{ :dependency_name => "ReactCommon/turbomodule/core" }
])
end
Expand Down
54 changes: 0 additions & 54 deletions scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,60 +328,6 @@ def test_fixLibrarySearchPaths_correctlySetsTheSearchPathsForAllProjects
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 #
# ===================================== #
Expand Down
5 changes: 3 additions & 2 deletions scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa
].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]
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/cocoapods/new_architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version)

spec.dependency "RCTRequired"
spec.dependency "RCTTypeSafety"
spec.dependency "ReactCommon/turbomodule/bridging"
spec.dependency "ReactCommon/turbomodule/core"
end
end
Expand Down
12 changes: 0 additions & 12 deletions scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ def self.fix_library_search_paths(installer)
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|
Expand Down
2 changes: 0 additions & 2 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -212,7 +211,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)
Expand Down

0 comments on commit ee1fb6f

Please sign in to comment.