Skip to content

Commit a56b832

Browse files
author
Siddharth Gupta
committed
Add Support for Fixing Swift Modular Imports
1 parent 27ba8c8 commit a56b832

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/cocoapods-pod-merge/Main.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def merge(merged_framework_name, group_contents, podfile_info)
247247
Dir.glob('**/*.{h,m,mm,swift}').each do |source_file|
248248
contents = File.read(source_file)
249249
if has_dependencies
250+
# Fix imports of style import xx
250251
pods_to_merge.each do |pod|
251252
modular_imports = contents.scan(%r{<#{pod}/(.+)>})
252253
next unless modular_imports&.last
@@ -257,6 +258,15 @@ def merge(merged_framework_name, group_contents, podfile_info)
257258
end
258259
File.open(source_file, 'w') { |file| file.puts contents_with_imports_fixed }
259260
end
261+
262+
# Fix imports of style import xx
263+
pods_to_merge.each do |pod|
264+
modular_imports = contents.scan("import #{pod}")
265+
next unless modular_imports&.last
266+
267+
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}", "") }
269+
end
260270
else
261271
modular_imports = contents.scan(%r{<#{pod}/(.+)>})
262272
next unless modular_imports&.last

0 commit comments

Comments
 (0)