Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -837,58 +837,6 @@ def test_updateSearchPaths_whenNotUseFrameworks_addsSearchPaths
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 #
# =============================================== #
Expand Down
37 changes: 0 additions & 37 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -556,43 +556,6 @@ 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)
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",
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down