Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use real_path to find plist files is update_ats Cocoapod util #42242

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? Should we add the path to it also?

end
end

Expand Down
13 changes: 6 additions & 7 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -580,16 +579,16 @@ 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

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
Expand Down
Loading