From e7caf781efdc093a413b9b112c9ada43af903f22 Mon Sep 17 00:00:00 2001 From: Chris Zubak-Skees Date: Thu, 11 Jan 2024 19:59:01 +0800 Subject: [PATCH] fix: use real_path to find plist files is update_ats Cocoapod util --- .../cocoapods/__tests__/test_utils/InstallerMock.rb | 2 ++ packages/react-native/scripts/cocoapods/utils.rb | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb index 6c0bfc7a353e76..b5fd92a4bce23a 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb @@ -134,10 +134,12 @@ def save() class PBXFileRefMock attr_reader :name attr_reader :path + attr_reader :real_path def initialize(name) @name = name @path = name + @real_path = name end end diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index d93183dbbe478d..a31ca32b4e7224 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -564,10 +564,9 @@ def self.get_plist_paths_from(user_project) 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) + def self.update_ats_in_plist(plistFiles) + plistFiles.each do |plistFile| + plist = Xcodeproj::Plist.read_from_path(plistFile.real_path) ats_configs = { "NSAllowsArbitraryLoads" => false, "NSAllowsLocalNetworking" => true, @@ -580,7 +579,7 @@ def self.update_ats_in_plist(plistPaths, parent) plist["NSAppTransportSecurity"] ||= {} plist["NSAppTransportSecurity"] = plist["NSAppTransportSecurity"].merge(ats_configs) end - Xcodeproj::Plist.write_to_path(plist, fullPlistPath) + Xcodeproj::Plist.write_to_path(plist, plistFile.real_path) end end @@ -588,8 +587,8 @@ 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) + plistFiles = self.get_plist_paths_from(user_project) + self.update_ats_in_plist(plistFiles) end def self.react_native_pods