Class: Pod::Generator::XCConfig::PrivatePodXCConfig

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

Overview

Generates the private xcconfigs for the pod targets.

The private xcconfig file for a Pod target merges the configuration values of the public namespaced xcconfig with the default private configuration values required by CocoaPods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, public_xcconfig) ⇒ PrivatePodXCConfig

Initialize a new instance

Parameters:

  • target (Target)

    @see target

  • public_xcconfig (Xcodeproj::Config)

    @see public_xcconfig



25
26
27
28
# File 'lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb', line 25

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

Instance Attribute Details

#public_xcconfigXcodeproj::Config (readonly)

Returns The public xcconfig which this one will use.

Returns:

  • (Xcodeproj::Config)

    The public xcconfig which this one will use.



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

def public_xcconfig
  @public_xcconfig
end

#targetTarget (readonly)

Returns the target represented by this xcconfig.

Returns:

  • (Target)

    the target represented by this xcconfig.



13
14
15
# File 'lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb', line 13

def target
  @target
end

#xcconfigXcodeproj::Config (readonly)

Returns The generated xcconfig.

Returns:

  • (Xcodeproj::Config)

    The generated xcconfig.



32
33
34
# File 'lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb', line 32

def xcconfig
  @xcconfig
end

Instance Method Details

#generateXcodeproj::Config

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
# File 'lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb', line 49

def generate
  target_search_paths = target.build_headers.search_paths(target.platform)
  sandbox_search_paths = target.sandbox.public_headers.search_paths(target.platform)
  search_paths = target_search_paths.concat(sandbox_search_paths).uniq

  config = {
    'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
    'PODS_ROOT'  => '${SRCROOT}',
    'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
    'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
    'SKIP_INSTALL' => 'YES',
    # 'USE_HEADERMAP' => 'NO'
  }

  if target.requires_frameworks? && target.scoped?
    # Only quote the FRAMEWORK_SEARCH_PATHS entry, because it’s a setting that takes multiple values.
    # In addition, quoting CONFIGURATION_BUILD_DIR would make it be interpreted as a relative path.
    build_settings = {
      'PODS_FRAMEWORK_BUILD_PATH' => target.configuration_build_dir,
      'FRAMEWORK_SEARCH_PATHS' => '"$PODS_FRAMEWORK_BUILD_PATH"',
      'CONFIGURATION_BUILD_DIR' => '$PODS_FRAMEWORK_BUILD_PATH',
    }
    config.merge!(build_settings)
  end

  xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, target.xcconfig_prefix)
  @xcconfig = Xcodeproj::Config.new(xcconfig_hash)
  XCConfigHelper.add_target_specific_settings(target, @xcconfig)
  @xcconfig.includes = [target.name]
  @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.



41
42
43
# File 'lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb', line 41

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