Class: Pod::Generator::PrefixHeader
- Defined in:
- lib/cocoapods/generator/prefix_header.rb
Overview
Generates a prefix header file for a Pods library. The prefix header is generated according to the platform of the target and the pods.
According to the platform the prefix header imports ‘UIKit/UIKit.h` or `Cocoa/Cocoa.h`.
Instance Attribute Summary collapse
-
#file_accessors ⇒ Array<FileAccessor>
readonly
The file accessors for which to generate the prefix header.
Attributes inherited from Header
#imports, #module_imports, #platform
Instance Method Summary collapse
-
#generate ⇒ String
Generates the contents of the prefix header according to the platform and the pods.
-
#initialize(file_accessors, platform) ⇒ PrefixHeader
constructor
Initialize a new instance.
Methods inherited from Header
Constructor Details
#initialize(file_accessors, platform) ⇒ PrefixHeader
Initialize a new instance
23 24 25 26 |
# File 'lib/cocoapods/generator/prefix_header.rb', line 23 def initialize(file_accessors, platform) @file_accessors = file_accessors super platform end |
Instance Attribute Details
#file_accessors ⇒ Array<FileAccessor> (readonly)
Returns The file accessors for which to generate the prefix header.
13 14 15 |
# File 'lib/cocoapods/generator/prefix_header.rb', line 13 def file_accessors @file_accessors end |
Instance Method Details
#generate ⇒ String
Subspecs can specify prefix header information too.
Check to see if we have a similar duplication issue with file_accessor.prefix_header.
Only unique prefix_header_contents are added to the prefix header.
Generates the contents of the prefix header according to the platform and the pods.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cocoapods/generator/prefix_header.rb', line 40 def generate result = super unique_prefix_header_contents = file_accessors.map do |file_accessor| file_accessor.spec_consumer.prefix_header_contents end.compact.uniq unique_prefix_header_contents.each do |prefix_header_contents| result << prefix_header_contents result << "\n" end file_accessors.map(&:prefix_header).compact.uniq.each do |prefix_header| result << Pathname(prefix_header).read end result end |