Class: Pod::Generator::ModuleMap

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/generator/module_map.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ ModuleMap

Initialize a new instance

Parameters:



21
22
23
24
# File 'lib/cocoapods/generator/module_map.rb', line 21

def initialize(target)
  @target = target
  @private_headers = []
end

Instance Attribute Details

#private_headersArray<#to_s>

Returns the private headers of the module.

Returns:

  • (Array<#to_s>)

    the private headers of the module



15
16
17
# File 'lib/cocoapods/generator/module_map.rb', line 15

def private_headers
  @private_headers
end

#targetPodTarget (readonly)

Returns the target represented by this Info.plist.

Returns:

  • (PodTarget)

    the target represented by this Info.plist.



11
12
13
# File 'lib/cocoapods/generator/module_map.rb', line 11

def target
  @target
end

Instance Method Details

#generateString

Generates the contents of the module.modulemap file.

Returns:

  • (String)


44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods/generator/module_map.rb', line 44

def generate
  result = "    framework module \#{target.product_module_name} {\n      umbrella header \"\#{target.umbrella_header_path.basename}\"\n\n      export *\n      module * { export * }\n  eos\n\n  result << \"\\n\#{generate_private_header_exports}\" unless private_headers.empty?\n  result << \"}\\n\"\nend\n".strip_heredoc

#save_as(path) ⇒ void

This method returns an undefined value.

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

Parameters:

  • path (Pathname)

    the path where the prefix header should be stored.



33
34
35
36
37
38
# File 'lib/cocoapods/generator/module_map.rb', line 33

def save_as(path)
  contents = generate
  path.open('w') do |f|
    f.write(contents)
  end
end