Skip to content

Commit 41c601e

Browse files
gabrieldonadelfacebook-github-bot
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. ## Changelog: [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 f4dbd15 commit 41c601e

File tree

3 files changed

+1
-91
lines changed

3 files changed

+1
-91
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
@@ -837,58 +837,6 @@ def test_updateSearchPaths_whenNotUseFrameworks_addsSearchPaths
837837
end
838838
end
839839

840-
# ============================== #
841-
# Test - Apply ATS configuration #
842-
# ============================== #
843-
844-
def test_applyATSConfig_plistNil
845-
# Arrange
846-
user_project_mock = prepare_user_project_mock_with_plists()
847-
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
848-
installer = InstallerMock.new(pods_projects_mock, [
849-
AggregatedProjectMock.new(user_project_mock)
850-
])
851-
852-
# # Act
853-
ReactNativePodsUtils.apply_ats_config(installer)
854-
855-
# # Assert
856-
assert_equal(user_project_mock.files.length, 2)
857-
user_project_mock.files.each do |file|
858-
path = File.join(user_project_mock.path.parent, file.name)
859-
plist = Xcodeproj::Plist.read_from_path(path)
860-
assert_equal(plist['NSAppTransportSecurity'], {
861-
'NSAllowsArbitraryLoads' => false,
862-
'NSAllowsLocalNetworking' => true,
863-
});
864-
end
865-
end
866-
867-
def test_applyATSConfig_plistNonNil
868-
# Arrange
869-
user_project_mock = prepare_user_project_mock_with_plists()
870-
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
871-
installer = InstallerMock.new(pods_projects_mock, [
872-
AggregatedProjectMock.new(user_project_mock)
873-
])
874-
Xcodeproj::Plist.write_to_path({}, "/test/Info.plist")
875-
Xcodeproj::Plist.write_to_path({}, "/test/Extension-Info.plist")
876-
877-
# # Act
878-
ReactNativePodsUtils.apply_ats_config(installer)
879-
880-
# # Assert
881-
assert_equal(user_project_mock.files.length, 2)
882-
user_project_mock.files.each do |file|
883-
path = File.join(user_project_mock.path.parent, file.name)
884-
plist = Xcodeproj::Plist.read_from_path(path)
885-
assert_equal(plist['NSAppTransportSecurity'], {
886-
'NSAllowsArbitraryLoads' => false,
887-
'NSAllowsLocalNetworking' => true,
888-
});
889-
end
890-
end
891-
892840
# =============================================== #
893841
# Test - Create Header Search Path For Frameworks #
894842
# =============================================== #

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

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

559-
def self.get_plist_paths_from(user_project)
560-
info_plists = user_project
561-
.files
562-
.select { |p|
563-
p.name&.end_with?('Info.plist')
564-
}
565-
return info_plists
566-
end
567-
568-
def self.update_ats_in_plist(plistPaths, parent)
569-
plistPaths.each do |plistPath|
570-
fullPlistPath = File.join(parent, plistPath.path)
571-
plist = Xcodeproj::Plist.read_from_path(fullPlistPath)
572-
ats_configs = {
573-
"NSAllowsArbitraryLoads" => false,
574-
"NSAllowsLocalNetworking" => true,
575-
}
576-
if plist.nil?
577-
plist = {
578-
"NSAppTransportSecurity" => ats_configs
579-
}
580-
else
581-
plist["NSAppTransportSecurity"] ||= {}
582-
plist["NSAppTransportSecurity"] = plist["NSAppTransportSecurity"].merge(ats_configs)
583-
end
584-
Xcodeproj::Plist.write_to_path(plist, fullPlistPath)
585-
end
586-
end
587-
588-
def self.apply_ats_config(installer)
589-
user_project = installer.aggregate_targets
590-
.map{ |t| t.user_project }
591-
.first
592-
plistPaths = self.get_plist_paths_from(user_project)
593-
self.update_ats_in_plist(plistPaths, user_project.path.parent)
594-
end
595-
596559
def self.react_native_pods
597560
return [
598561
"DoubleConversion",

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ def react_native_post_install(
285285
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
286286
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
287287
ReactNativePodsUtils.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled)
288-
ReactNativePodsUtils.apply_xcode_15_patch(installer)
289-
ReactNativePodsUtils.apply_ats_config(installer)
288+
ReactNativePodsUtils.apply_xcode_15_patch(installer)
290289
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
291290
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
292291
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)

0 commit comments

Comments
 (0)