Class: Pod::Generator::XCConfig
- Inherits:
-
Object
- Object
- Pod::Generator::XCConfig
- Defined in:
- lib/cocoapods/generator/xcconfig.rb
Overview
Generates an xcconfig file for each target of the Pods project. The configuration file should be used by the user target as well.
Instance Attribute Summary collapse
-
#relative_pods_root ⇒ String
readonly
The relative path of the Pods root respect the user project that should be integrated by this library.
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods project is installed.
-
#set_arc_compatibility_flag ⇒ Bool
Whether the Podfile specifies to add the ‘-fobjc-arc` flag for compatibility.
-
#spec_consumers ⇒ Array<Specification::Consumer>
readonly
The consumers for the specifications of the library which needs the xcconfig.
-
#xcconfig ⇒ Xcodeproj::Config
readonly
The generated xcconfig.
Class Method Summary collapse
-
.pods_project_settings ⇒ Hash
The settings of the xcconfig that the Pods project needs to override.
Instance Method Summary collapse
-
#generate ⇒ Xcodeproj::Config
Generates the xcconfig for the library.
-
#initialize(sandbox, spec_consumers, relative_pods_root) ⇒ XCConfig
constructor
A new instance of XCConfig.
-
#save_as(path) ⇒ void
Generates and saves the xcconfig to the given path.
Constructor Details
#initialize(sandbox, spec_consumers, relative_pods_root) ⇒ XCConfig
Returns a new instance of XCConfig.
27 28 29 30 31 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 27 def initialize(sandbox, spec_consumers, relative_pods_root) @sandbox = sandbox @spec_consumers = spec_consumers @relative_pods_root = relative_pods_root end |
Instance Attribute Details
#relative_pods_root ⇒ String (readonly)
Returns the relative path of the Pods root respect the user project that should be integrated by this library.
21 22 23 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 21 def relative_pods_root @relative_pods_root end |
#sandbox ⇒ Sandbox (readonly)
Returns the sandbox where the Pods project is installed.
11 12 13 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 11 def sandbox @sandbox end |
#set_arc_compatibility_flag ⇒ Bool
Returns whether the Podfile specifies to add the ‘-fobjc-arc` flag for compatibility.
36 37 38 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 36 def set_arc_compatibility_flag @set_arc_compatibility_flag end |
#spec_consumers ⇒ Array<Specification::Consumer> (readonly)
Returns the consumers for the specifications of the library which needs the xcconfig.
16 17 18 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 16 def spec_consumers @spec_consumers end |
#xcconfig ⇒ Xcodeproj::Config (readonly)
Returns The generated xcconfig.
73 74 75 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 73 def xcconfig @xcconfig end |
Class Method Details
.pods_project_settings ⇒ Hash
Returns The settings of the xcconfig that the Pods project needs to override.
78 79 80 81 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 78 def self.pods_project_settings { 'PODS_ROOT' => '${SRCROOT}', 'PODS_HEADERS_SEARCH_PATHS' => '${PODS_BUILD_HEADERS_SEARCH_PATHS}' } end |
Instance Method Details
#generate ⇒ Xcodeproj::Config
The value ‘PODS_HEADERS_SEARCH_PATHS` is used to store the headers so xcconfig can reference the variable.
Generates the xcconfig for the library.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 47 def generate ld_flags = '-ObjC' if set_arc_compatibility_flag && spec_consumers.any? { |consumer| consumer.requires_arc } ld_flags << ' -fobjc-arc' end @xcconfig = Xcodeproj::Config.new({ 'ALWAYS_SEARCH_USER_PATHS' => 'YES', 'OTHER_LDFLAGS' => ld_flags, 'HEADER_SEARCH_PATHS' => '${PODS_HEADERS_SEARCH_PATHS}', 'PODS_ROOT' => relative_pods_root, 'PODS_HEADERS_SEARCH_PATHS' => '${PODS_PUBLIC_HEADERS_SEARCH_PATHS}', 'PODS_BUILD_HEADERS_SEARCH_PATHS' => quote(sandbox.build_headers.search_paths), 'PODS_PUBLIC_HEADERS_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths), 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' }) spec_consumers.each do |consumer| add_spec_build_settings_to_xcconfig(consumer, @xcconfig) end @xcconfig end |
#save_as(path) ⇒ void
This method returns an undefined value.
Generates and saves the xcconfig to the given path.
90 91 92 |
# File 'lib/cocoapods/generator/xcconfig.rb', line 90 def save_as(path) path.open('w') { |file| file.write(generate) } end |