From a0b76d90b73ec0d3d9e0174004bfb96a5b6f3a3e Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Mon, 11 Dec 2023 06:33:05 -0800 Subject: [PATCH] Fix NSAppTransportSecurity being overwritten during pod install (#41875) Summary: This PR fixes https://github.com/facebook/react-native/issues/41874. ## Changelog: [iOS] [Fixed] - Fix NSAppTransportSecurity being overwritten during pod install Pull Request resolved: https://github.com/facebook/react-native/pull/41875 Test Plan: 1. Delete the whole `NSAppTransportSecurity` in Info.plist and run `pod install`: `NSAllowsArbitraryLoads` and `NSAllowsLocalNetworking` are added as expected. 2. Modify `NSAppTransportSecurity` to only contain `NSExceptionDomains` and run `pod install`: `NSAllowsArbitraryLoads` and `NSAllowsLocalNetworking` are added, and `NSExceptionDomains` is still there. 3. Run `pod install` again: nothing changes. Reviewed By: christophpurrer Differential Revision: D52032400 Pulled By: dmytrorykun fbshipit-source-id: 48cf29809c283af80613ffbf1ac0dc663a0a2fb5 --- packages/react-native/scripts/cocoapods/utils.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index ace3848aa849d7..dcb15c397d0196 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -541,7 +541,8 @@ def self.update_ats_in_plist(plistPaths, parent) "NSAppTransportSecurity" => ats_configs } else - plist["NSAppTransportSecurity"] = ats_configs + plist["NSAppTransportSecurity"] ||= {} + plist["NSAppTransportSecurity"] = plist["NSAppTransportSecurity"].merge(ats_configs) end Xcodeproj::Plist.write_to_path(plist, fullPlistPath) end