mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: cherry-pick changes from https://github.com/facebook/react-native/issues/34214 to main. because the `react_native_pods.rb` on main is quite different from 0.69, i have separated pr for the change. ## Changelog [iOS] [Fixed] - Fix React-bridging headers import not found Pull Request resolved: https://github.com/facebook/react-native/pull/34271 Test Plan: RNTester + pod install and verify pod targets to have `React-bridging` in header search paths. Reviewed By: cipolleschi Differential Revision: D38122074 Pulled By: dmitryrykun fbshipit-source-id: 64569abbfa3a684f0d6b84c9e3222bfc9a171061
This commit is contained in:
committed by
Lorenzo Sciandra
parent
70daa6e728
commit
5fc88e95b5
@@ -208,10 +208,8 @@ def prepare_CXX_Flags_build_configuration(name)
|
||||
end
|
||||
|
||||
def prepare_pod_target_installation_results_mock(name, configs)
|
||||
return PodTargetInstallationResultsMock.new(
|
||||
:name => name,
|
||||
:native_target => TargetMock.new(name, configs)
|
||||
)
|
||||
target = TargetMock.new(name, configs)
|
||||
return TargetInstallationResultMock.new(target, target)
|
||||
end
|
||||
|
||||
def prepare_installer_for_cpp_flags(xcconfigs, build_configs)
|
||||
@@ -232,8 +230,6 @@ def prepare_installer_for_cpp_flags(xcconfigs, build_configs)
|
||||
[
|
||||
AggregatedProjectMock.new(:xcconfigs => xcconfigs_map, :base_path => "a/path/")
|
||||
],
|
||||
:target_installation_results => TargetInstallationResultsMock.new(
|
||||
:pod_target_installation_results => pod_target_installation_results_map
|
||||
)
|
||||
:pod_target_installation_results => pod_target_installation_results_map
|
||||
)
|
||||
end
|
||||
|
||||
@@ -41,10 +41,23 @@ class InstallerMock
|
||||
attr_reader :aggregate_targets
|
||||
attr_reader :target_installation_results
|
||||
|
||||
def initialize(pods_project = PodsProjectMock.new, aggregate_targets = [AggregatedProjectMock.new], target_installation_results: [])
|
||||
InstallationResults = Struct.new(:pod_target_installation_results, :aggregate_target_installation_results)
|
||||
|
||||
def initialize(pods_project = PodsProjectMock.new, aggregate_targets = [AggregatedProjectMock.new],
|
||||
pod_target_installation_results: {},
|
||||
aggregate_target_installation_results: {})
|
||||
@pods_project = pods_project
|
||||
@aggregate_targets = aggregate_targets
|
||||
@target_installation_results = target_installation_results
|
||||
|
||||
@target_installation_results = InstallationResults.new(pod_target_installation_results, aggregate_target_installation_results)
|
||||
aggregate_targets.each do |aggregate_target|
|
||||
aggregate_target.user_project.native_targets.each do |target|
|
||||
@target_installation_results.pod_target_installation_results[target.name] = TargetInstallationResultMock.new(target, target)
|
||||
end
|
||||
end
|
||||
pods_project.native_targets.each do |target|
|
||||
@target_installation_results.pod_target_installation_results[target.name] = TargetInstallationResultMock.new(target, target)
|
||||
end
|
||||
end
|
||||
|
||||
def target_with_name(name)
|
||||
@@ -168,20 +181,27 @@ class BuildConfigurationMock
|
||||
end
|
||||
end
|
||||
|
||||
class TargetInstallationResultsMock
|
||||
attr_reader :pod_target_installation_results
|
||||
|
||||
def initialize(pod_target_installation_results: {})
|
||||
@pod_target_installation_results = pod_target_installation_results
|
||||
end
|
||||
end
|
||||
|
||||
class PodTargetInstallationResultsMock
|
||||
attr_reader :name
|
||||
class TargetInstallationResultMock
|
||||
attr_reader :target
|
||||
attr_reader :native_target
|
||||
attr_reader :resource_bundle_targets
|
||||
attr_reader :test_native_targets
|
||||
attr_reader :test_resource_bundle_targets
|
||||
attr_reader :test_app_host_targets
|
||||
attr_reader :app_native_targets
|
||||
attr_reader :app_resource_bundle_targets
|
||||
|
||||
def initialize(name: "", native_target: TargetMock.new())
|
||||
@name = name
|
||||
def initialize(target = TargetMock, native_target = TargetMock,
|
||||
resource_bundle_targets = [], test_native_targets = [],
|
||||
test_resource_bundle_targets = {}, test_app_host_targets = [],
|
||||
app_native_targets = {}, app_resource_bundle_targets = {})
|
||||
@target = target
|
||||
@native_target = native_target
|
||||
@resource_bundle_targets = resource_bundle_targets
|
||||
@test_native_targets = test_native_targets
|
||||
@test_resource_bundle_targets = test_resource_bundle_targets
|
||||
@test_app_host_targets = test_app_host_targets
|
||||
@app_native_targets = app_native_targets
|
||||
@app_resource_bundle_targets = app_resource_bundle_targets
|
||||
end
|
||||
end
|
||||
|
||||
@@ -315,6 +315,60 @@ 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 Mac Catalyst Patches #
|
||||
# ================================= #
|
||||
|
||||
@@ -93,6 +93,18 @@ 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|
|
||||
|
||||
@@ -156,6 +156,7 @@ 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