class Pod::Generator::ModuleMap

Generates LLVM module map files. A module map file is generated for each Pod and for each Pod target definition that is built as a framework. It specifies a different umbrella header than usual to avoid name conflicts with existing headers of the podspec.

Constants

Attributes

headers[R]
target[R]

@return [PodTarget, AggregateTarget] the target the module map is generated for.

Public Class Methods

new(target) click to toggle source

Initialize a new instance

@param [PodTarget, AggregateTarget] target @see target

# File lib/cocoapods/generator/module_map.rb, line 43
def initialize(target)
  @target = target
  @headers = [
    Header.new(target.umbrella_header_path.basename, true),
  ]
end

Public Instance Methods

generate() click to toggle source

Generates the contents of the module.modulemap file.

@return [String]

# File lib/cocoapods/generator/module_map.rb, line 68
      def generate
        <<-MODULE_MAP.strip_heredoc
#{module_specifier_prefix}module #{target.product_module_name}#{module_declaration_attributes} {
  #{headers.join("\n  ")}

  export *
  module * { export * }
}
        MODULE_MAP
      end
save_as(path) click to toggle source

Generates and saves the Info.plist to the given path.

@param [Pathname] path

the path where the prefix header should be stored.

@return [void]

# File lib/cocoapods/generator/module_map.rb, line 57
def save_as(path)
  contents = generate
  path.open('w') do |f|
    f.write(contents)
  end
end

Private Instance Methods

module_declaration_attributes() click to toggle source

The suffix attributes to ‘module`.

# File lib/cocoapods/generator/module_map.rb, line 94
def module_declaration_attributes
  ''
end
module_specifier_prefix() click to toggle source

The prefix to ‘module` to prepend in the module map. Ensures that only framework targets have `framework` prepended.

# File lib/cocoapods/generator/module_map.rb, line 84
def module_specifier_prefix
  if target.build_as_framework?
    'framework '
  else
    ''
  end
end