mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f4dbd15f0b
commit
41c601e478
@@ -837,58 +837,6 @@ class UtilsTests < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
# ============================== #
|
||||
# Test - Apply ATS configuration #
|
||||
# ============================== #
|
||||
|
||||
def test_applyATSConfig_plistNil
|
||||
# Arrange
|
||||
user_project_mock = prepare_user_project_mock_with_plists()
|
||||
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
|
||||
installer = InstallerMock.new(pods_projects_mock, [
|
||||
AggregatedProjectMock.new(user_project_mock)
|
||||
])
|
||||
|
||||
# # Act
|
||||
ReactNativePodsUtils.apply_ats_config(installer)
|
||||
|
||||
# # Assert
|
||||
assert_equal(user_project_mock.files.length, 2)
|
||||
user_project_mock.files.each do |file|
|
||||
path = File.join(user_project_mock.path.parent, file.name)
|
||||
plist = Xcodeproj::Plist.read_from_path(path)
|
||||
assert_equal(plist['NSAppTransportSecurity'], {
|
||||
'NSAllowsArbitraryLoads' => false,
|
||||
'NSAllowsLocalNetworking' => true,
|
||||
});
|
||||
end
|
||||
end
|
||||
|
||||
def test_applyATSConfig_plistNonNil
|
||||
# Arrange
|
||||
user_project_mock = prepare_user_project_mock_with_plists()
|
||||
pods_projects_mock = PodsProjectMock.new([], {"some_pod" => {}})
|
||||
installer = InstallerMock.new(pods_projects_mock, [
|
||||
AggregatedProjectMock.new(user_project_mock)
|
||||
])
|
||||
Xcodeproj::Plist.write_to_path({}, "/test/Info.plist")
|
||||
Xcodeproj::Plist.write_to_path({}, "/test/Extension-Info.plist")
|
||||
|
||||
# # Act
|
||||
ReactNativePodsUtils.apply_ats_config(installer)
|
||||
|
||||
# # Assert
|
||||
assert_equal(user_project_mock.files.length, 2)
|
||||
user_project_mock.files.each do |file|
|
||||
path = File.join(user_project_mock.path.parent, file.name)
|
||||
plist = Xcodeproj::Plist.read_from_path(path)
|
||||
assert_equal(plist['NSAppTransportSecurity'], {
|
||||
'NSAllowsArbitraryLoads' => false,
|
||||
'NSAllowsLocalNetworking' => true,
|
||||
});
|
||||
end
|
||||
end
|
||||
|
||||
# =============================================== #
|
||||
# Test - Create Header Search Path For Frameworks #
|
||||
# =============================================== #
|
||||
|
||||
@@ -556,43 +556,6 @@ class ReactNativePodsUtils
|
||||
ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths)
|
||||
end
|
||||
|
||||
def self.get_plist_paths_from(user_project)
|
||||
info_plists = user_project
|
||||
.files
|
||||
.select { |p|
|
||||
p.name&.end_with?('Info.plist')
|
||||
}
|
||||
return info_plists
|
||||
end
|
||||
|
||||
def self.update_ats_in_plist(plistPaths, parent)
|
||||
plistPaths.each do |plistPath|
|
||||
fullPlistPath = File.join(parent, plistPath.path)
|
||||
plist = Xcodeproj::Plist.read_from_path(fullPlistPath)
|
||||
ats_configs = {
|
||||
"NSAllowsArbitraryLoads" => false,
|
||||
"NSAllowsLocalNetworking" => true,
|
||||
}
|
||||
if plist.nil?
|
||||
plist = {
|
||||
"NSAppTransportSecurity" => ats_configs
|
||||
}
|
||||
else
|
||||
plist["NSAppTransportSecurity"] ||= {}
|
||||
plist["NSAppTransportSecurity"] = plist["NSAppTransportSecurity"].merge(ats_configs)
|
||||
end
|
||||
Xcodeproj::Plist.write_to_path(plist, fullPlistPath)
|
||||
end
|
||||
end
|
||||
|
||||
def self.apply_ats_config(installer)
|
||||
user_project = installer.aggregate_targets
|
||||
.map{ |t| t.user_project }
|
||||
.first
|
||||
plistPaths = self.get_plist_paths_from(user_project)
|
||||
self.update_ats_in_plist(plistPaths, user_project.path.parent)
|
||||
end
|
||||
|
||||
def self.react_native_pods
|
||||
return [
|
||||
"DoubleConversion",
|
||||
|
||||
@@ -285,8 +285,7 @@ def react_native_post_install(
|
||||
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
|
||||
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
|
||||
ReactNativePodsUtils.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled)
|
||||
ReactNativePodsUtils.apply_xcode_15_patch(installer)
|
||||
ReactNativePodsUtils.apply_ats_config(installer)
|
||||
ReactNativePodsUtils.apply_xcode_15_patch(installer)
|
||||
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
|
||||
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
|
||||
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)
|
||||
|
||||
Reference in New Issue
Block a user