diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb index 6c0bfc7a353e76..0866d858577a36 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb @@ -139,6 +139,10 @@ def initialize(name) @name = name @path = name end + + def real_path + @path + end end class XCConfigMock diff --git a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb index cc6963c73a4fc0..7c47839089df94 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb @@ -797,6 +797,8 @@ def test_updateSearchPaths_whenNotUseFrameworks_addsSearchPaths def test_applyATSConfig_plistNil # Arrange + FileMock.mocked_existing_files("Info.plist") + FileMock.mocked_existing_files("Extension-Info.plist") user_project_mock = prepare_user_project_mock_with_plists() pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}}) installer = InstallerMock.new(pods_projects_mock, [ @@ -804,7 +806,7 @@ def test_applyATSConfig_plistNil ]) # # Act - ReactNativePodsUtils.apply_ats_config(installer) + ReactNativePodsUtils.apply_ats_config(installer, file_manager: FileMock) # # Assert assert_equal(user_project_mock.files.length, 2) @@ -820,6 +822,8 @@ def test_applyATSConfig_plistNil def test_applyATSConfig_plistNonNil # Arrange + FileMock.mocked_existing_files("Info.plist") + FileMock.mocked_existing_files("Extension-Info.plist") user_project_mock = prepare_user_project_mock_with_plists() pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}}) installer = InstallerMock.new(pods_projects_mock, [ @@ -829,7 +833,7 @@ def test_applyATSConfig_plistNonNil Xcodeproj::Plist.write_to_path({}, "/test/Extension-Info.plist") # # Act - ReactNativePodsUtils.apply_ats_config(installer) + ReactNativePodsUtils.apply_ats_config(installer, file_manager: FileMock) # # Assert assert_equal(user_project_mock.files.length, 2) diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index ace3848aa849d7..df489b40f38d1e 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -519,11 +519,11 @@ def self.set_imagemanager_search_path(target_installation_result) ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths) end - def self.get_plist_paths_from(user_project) + def self.get_plist_paths_from(user_project, file_manager) info_plists = user_project .files .select { |p| - p.name&.end_with?('Info.plist') + file_manager.exist?(p.real_path) && p.name&.end_with?('Info.plist') } return info_plists end @@ -547,11 +547,11 @@ def self.update_ats_in_plist(plistPaths, parent) end end - def self.apply_ats_config(installer) + def self.apply_ats_config(installer, file_manager: File) user_project = installer.aggregate_targets .map{ |t| t.user_project } .first - plistPaths = self.get_plist_paths_from(user_project) + plistPaths = self.get_plist_paths_from(user_project, file_manager) self.update_ats_in_plist(plistPaths, user_project.path.parent) end