Module: CocoapodsNameMappedModuleHooks::Helper

Defined in:
lib/cocoapods-NameMappedModule/helper/name_mapped_module_helper.rb

Instance Method Summary collapse

Instance Method Details

#generate(context, args = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods-NameMappedModule/helper/name_mapped_module_helper.rb', line 7

def generate(context, args = {})
  puts ' ⚠️  podspec name <==> module name'
  name_framework_mapping = {}
  context.umbrella_targets.each { |t|
    t.specs.each { |s|
      name_framework_mapping[s.root.name] = if s.root.module_name
                                              "#{s.root.module_name}.framework"
                                            else
                                              "#{s.root.name}.framework"
                                            end
    }
  }

  puts "🚗 name_framework_mapping"
  pp name_framework_mapping

  file = args[:output]
  if file
    File.open(file, 'w+') { |f| f.write(JSON.pretty_generate(name_framework_mapping)) }
    puts " 🚙 write name_framework_mapping hash to #{file}"
  end

  name_framework_mapping
end