Skip to content

Commit 7d5d355

Browse files
gabrieldonadelblakef
authored andcommitted
Remove ATS config patch from react_native_post_install (#42637)
Summary: This PR removes the `apply_ats_config` function of ReactNativePodsUtils that was used inside `react_native_post_install` because it was preventing users from configuring `NSAllowsArbitraryLoads` to true in their projects, especially when building in CI as the plist file would be reset after running pod install. [IOS] [CHANGED] - Remove ATS config patch from react_native_post_install Pull Request resolved: #42637 Test Plan: Edit `Info.plist`, run `pod install` and check if changes have not been overwritten Reviewed By: cortinico Differential Revision: D53048299 Pulled By: cipolleschi fbshipit-source-id: 8dc335fae2e05a62daf931a50fa3f7a314e76a2e
1 parent 6f92fb9 commit 7d5d355

File tree

3 files changed

+1
-90
lines changed

3 files changed

+1
-90
lines changed

packages/react-native/scripts/cocoapods/__tests__/utils-test.rb

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -945,58 +945,6 @@ def test_applyFlagsForFabric_whenFabricDisabled_doNothing
945945
end
946946
end
947947

948-
# ============================== #
949-
# Test - Apply ATS configuration #
950-
# ============================== #
951-
952-
def test_applyATSConfig_plistNil
953-
# Arrange
954-
user_project_mock = prepare_user_project_mock_with_plists()
955-
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
956-
installer = InstallerMock.new(pods_projects_mock, [
957-
AggregatedProjectMock.new(user_project_mock)
958-
])
959-
960-
# # Act
961-
ReactNativePodsUtils.apply_ats_config(installer)
962-
963-
# # Assert
964-
assert_equal(user_project_mock.files.length, 2)
965-
user_project_mock.files.each do |file|
966-
path = File.join(user_project_mock.path.parent, file.name)
967-
plist = Xcodeproj::Plist.read_from_path(path)
968-
assert_equal(plist['NSAppTransportSecurity'], {
969-
'NSAllowsArbitraryLoads' => false,
970-
'NSAllowsLocalNetworking' => true,
971-
});
972-
end
973-
end
974-
975-
def test_applyATSConfig_plistNonNil
976-
# Arrange
977-
user_project_mock = prepare_user_project_mock_with_plists()
978-
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
979-
installer = InstallerMock.new(pods_projects_mock, [
980-
AggregatedProjectMock.new(user_project_mock)
981-
])
982-
Xcodeproj::Plist.write_to_path({}, "/test/Info.plist")
983-
Xcodeproj::Plist.write_to_path({}, "/test/Extension-Info.plist")
984-
985-
# # Act
986-
ReactNativePodsUtils.apply_ats_config(installer)
987-
988-
# # Assert
989-
assert_equal(user_project_mock.files.length, 2)
990-
user_project_mock.files.each do |file|
991-
path = File.join(user_project_mock.path.parent, file.name)
992-
plist = Xcodeproj::Plist.read_from_path(path)
993-
assert_equal(plist['NSAppTransportSecurity'], {
994-
'NSAllowsArbitraryLoads' => false,
995-
'NSAllowsLocalNetworking' => true,
996-
});
997-
end
998-
end
999-
1000948
# =============================================== #
1001949
# Test - Create Header Search Path For Frameworks #
1002950
# =============================================== #

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -538,43 +538,6 @@ def self.set_imagemanager_search_path(target_installation_result)
538538
ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths)
539539
end
540540

541-
def self.get_plist_paths_from(user_project)
542-
info_plists = user_project
543-
.files
544-
.select { |p|
545-
p.name&.end_with?('Info.plist')
546-
}
547-
return info_plists
548-
end
549-
550-
def self.update_ats_in_plist(plistPaths, parent)
551-
plistPaths.each do |plistPath|
552-
fullPlistPath = File.join(parent, plistPath.path)
553-
plist = Xcodeproj::Plist.read_from_path(fullPlistPath)
554-
ats_configs = {
555-
"NSAllowsArbitraryLoads" => false,
556-
"NSAllowsLocalNetworking" => true,
557-
}
558-
if plist.nil?
559-
plist = {
560-
"NSAppTransportSecurity" => ats_configs
561-
}
562-
else
563-
plist["NSAppTransportSecurity"] ||= {}
564-
plist["NSAppTransportSecurity"] = plist["NSAppTransportSecurity"].merge(ats_configs)
565-
end
566-
Xcodeproj::Plist.write_to_path(plist, fullPlistPath)
567-
end
568-
end
569-
570-
def self.apply_ats_config(installer)
571-
user_project = installer.aggregate_targets
572-
.map{ |t| t.user_project }
573-
.first
574-
plistPaths = self.get_plist_paths_from(user_project)
575-
self.update_ats_in_plist(plistPaths, user_project.path.parent)
576-
end
577-
578541
def self.react_native_pods
579542
return [
580543
"DoubleConversion",

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ def react_native_post_install(
306306
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
307307
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
308308
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: fabric_enabled)
309+
ReactNativePodsUtils.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled)
309310
ReactNativePodsUtils.apply_xcode_15_patch(installer)
310-
ReactNativePodsUtils.apply_ats_config(installer)
311311
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
312312

313313
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)

0 commit comments

Comments
 (0)