Skip to content

Commit fff1d60

Browse files
philIipfacebook-github-bot
authored andcommitted
adjust ats settings in plist in pod install (facebook#38086)
Summary: Pull Request resolved: facebook#38086 Changelog: [Internal] in this diff, we update the developer's Info.plists to have the correct ATS settings introducing usage of products: https://www.rubydoc.info/github/CocoaPods/Xcodeproj/Xcodeproj/Project#products-instance_method, in order to retrieve the plists Differential Revision: D47041590 fbshipit-source-id: 4118127e7be5374ff8bb7225ebdf6b00e06f7177
1 parent f6c2912 commit fff1d60

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,42 @@ def self.set_imagemanager_search_path(target_installation_result)
396396
])
397397
end
398398

399+
def self.get_plist_paths_from(user_project)
400+
info_plists = user_project
401+
.products
402+
.select { |p|
403+
p.name&.end_with?('Info.plist')
404+
}
405+
return info_plists
406+
end
407+
408+
def self.update_ats_in_plist(plistPaths, parent)
409+
plistPaths.each do |plistPath|
410+
fullPlistPath = File.join(parent, plistPath.path)
411+
plist = Xcodeproj::Plist.read_from_path(fullPlistPath)
412+
ats_configs = {
413+
"NSAllowsArbitraryLoads" => false,
414+
"NSAllowsLocalNetworking" => true,
415+
}
416+
if plist.nil?
417+
plist = {
418+
"NSAppTransportSecurity" => ats_configs
419+
}
420+
else
421+
plist["NSAppTransportSecurity"] = ats_configs
422+
end
423+
Xcodeproj::Plist.write_to_path(plist, fullPlistPath)
424+
end
425+
end
426+
427+
def self.apply_ats_config(installer)
428+
user_project = installer.aggregate_targets
429+
.map{ |t| t.user_project }
430+
.first
431+
plistPaths = self.get_plist_paths_from(user_project)
432+
self.update_ats_in_plist(plistPaths, user_project.path.parent)
433+
end
434+
399435
def self.react_native_pods
400436
return [
401437
"DoubleConversion",

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def react_native_post_install(
246246
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
247247
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: fabric_enabled)
248248
ReactNativePodsUtils.apply_xcode_15_patch(installer)
249+
ReactNativePodsUtils.apply_ats_config(installer)
249250

250251
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
251252
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == "1"

0 commit comments

Comments
 (0)