Skip to content

Commit f0f080d

Browse files
author
Siddharth Gupta
committed
Automatically Add MergeFile to Pods Project
1 parent 1ad5690 commit f0f080d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/cocoapods-pod-merge/Main.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ def begin(_installer_context)
7272
add_to_gitignore
7373
end
7474

75+
def add_mergefile_to_project(installer_context)
76+
pods_project = Xcodeproj::Project.open(installer_context.pods_project.path)
77+
mergefile = pods_project.new_file('../MergeFile')
78+
mergefile.explicit_file_type = 'text.script.ruby'
79+
mergefile.include_in_index = '1'
80+
pods_project.save
81+
end
82+
7583
def add_to_gitignore
7684
gitignore_file = '.gitignore'
7785

@@ -265,7 +273,7 @@ def merge(merged_framework_name, group_contents, podfile_info)
265273
next unless modular_imports&.last
266274

267275
Pod::UI.puts "\t\tExperimental: ".yellow + "Found a module import in #{source_file}, fixing this by removing it".magenta
268-
File.open(source_file, 'w') { |file| file.puts contents.gsub("import #{pod}", "") }
276+
File.open(source_file, 'w') { |file| file.puts contents.gsub("import #{pod}", '') }
269277
end
270278
else
271279
modular_imports = contents.scan(%r{<#{pod}/(.+)>})

lib/cocoapods_plugin.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ module CocoapodsPodMerge
77
Pod::HooksManager.register('cocoapods-pod-merge', :pre_install) do |installer_context|
88
PodMerger.new.begin(installer_context)
99
end
10+
11+
Pod::HooksManager.register('cocoapods-pod-merge', :post_install) do |installer_context|
12+
PodMerger.new.add_mergefile_to_project(installer_context)
13+
end
1014
end
1115

0 commit comments

Comments
 (0)