Class: Pod::Generator::XCConfig::AggregateXCConfig

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

Overview

Generates the xcconfigs for the aggregate targets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, configuration_name) ⇒ AggregateXCConfig

Returns a new instance of AggregateXCConfig.

Parameters:

  • target (Target)

    @see target

  • configuration_name (String)

    The name of the build configuration to generate this xcconfig for.



17
18
19
20
# File 'lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb', line 17

def initialize(target, configuration_name)
  @target = target
  @configuration_name = configuration_name
end

Instance Attribute Details

#targetTarget (readonly)

Returns the target represented by this xcconfig.

Returns:

  • (Target)

    the target represented by this xcconfig.



9
10
11
# File 'lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb', line 9

def target
  @target
end

#xcconfigXcodeproj::Config (readonly)

Returns The generated xcconfig.

Returns:

  • (Xcodeproj::Config)

    The generated xcconfig.



24
25
26
# File 'lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb', line 24

def xcconfig
  @xcconfig
end

Instance Method Details

#generateXcodeproj::Config

TODO:

This doesn’t include the specs xcconfigs anymore and now the logic is duplicated.

Note:

The xcconfig file for a Pods integration target includes the namespaced xcconfig files for each spec target dependency. Each namespaced configuration value is merged into the Pod xcconfig file.

Generates the xcconfig.

Returns:

  • (Xcodeproj::Config)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb', line 49

def generate
  header_search_path_flags = target.sandbox.public_headers.search_paths
  @xcconfig = Xcodeproj::Config.new(
                                      'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
                                      'OTHER_LIBTOOLFLAGS' => '$(OTHER_LDFLAGS)',
                                      'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
                                      'PODS_ROOT' => target.relative_pods_root,
                                      'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
                                      'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem')
                                    )

  target.pod_targets.each do |pod_target|
    next unless pod_target.include_in_build_config?(@configuration_name)

    pod_target.file_accessors.each do |file_accessor|
      XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
      file_accessor.vendored_frameworks.each do |vendored_framework|
        XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root)
      end
      file_accessor.vendored_libraries.each do |vendored_library|
        XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root)
      end
    end

    # Add pod static lib to list of libraries that are to be linked with
    # the user’s project.

    @xcconfig.merge!('OTHER_LDFLAGS' => %(-l "#{pod_target.name}"))
  end

  # TODO Need to decide how we are going to ensure settings like these
  # are always excluded from the user's project.
  #
  # See https://github.com/CocoaPods/CocoaPods/issues/1216
  @xcconfig.attributes.delete('USE_HEADERMAP')

  @xcconfig
end

#save_as(path) ⇒ void

This method returns an undefined value.

Generates and saves the xcconfig to the given path.

Parameters:

  • path (Pathname)

    the path where the prefix header should be stored.



33
34
35
# File 'lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb', line 33

def save_as(path)
  generate.save_as(path)
end