Class: Xcodeproj::Project::Object::XCBuildConfiguration

Inherits:
AbstractObject
  • Object
show all
Defined in:
lib/xcodeproj/project/object/build_configuration.rb,
lib/xcodeproj/project/object/helpers/build_settings_array_settings_by_object_version.rb

Overview

Encapsulates the information a specific build configuration referenced by a XCConfigurationList which in turn might be referenced by a PBXProject or a PBXNativeTarget.

Defined Under Namespace

Modules: BuildSettingsArraySettingsByObjectVersion

Attributes collapse

Attributes inherited from AbstractObject

#isa, #project, #uuid

AbstractObject Hooks collapse

Helpers collapse

Methods inherited from AbstractObject

#<=>, #==, #ascii_plist_annotation, #display_name, #inspect, isa, #nested_object_for_hash, #remove_from_project, #sort_recursively, #to_ascii_plist, #to_hash

Instance Attribute Details

#base_configuration_referencePBXFileReference

Returns an optional file reference to a configuration file (‘.xcconfig`).

Returns:

  • (PBXFileReference)

    an optional file reference to a configuration file (‘.xcconfig`).



28
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 28

has_one :base_configuration_reference, PBXFileReference

#base_configuration_reference_anchorPBXFileSystemSynchronizedRootGroup

Note:

the configuration file relative path must be provided in ‘base_configuration_reference_relative_path`

Returns an optional reference to a group synchronized with the file system that contains a configuration file (‘.xcconfig`).

Returns:



35
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 35

has_one :base_configuration_reference_anchor, PBXFileSystemSynchronizedRootGroup

#base_configuration_reference_relative_pathString

Note:

the configuration file group must be provided in ‘base_configuration_reference_anchor`

Returns the relative path of a configuration file (‘.xcconfig`) inside a group synchronized with the file system.

Returns:

  • (String)

    the relative path of a configuration file (‘.xcconfig`) inside a group synchronized with the file system.



42
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 42

attribute :base_configuration_reference_relative_path, String

#build_settingsHash

Returns the build settings to use for building the target.

Returns:

  • (Hash)

    the build settings to use for building the target.



23
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 23

attribute :build_settings, Hash, {}

#nameString

Returns the name of the configuration.

Returns:

  • (String)

    the name of the configuration.



19
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 19

attribute :name, String

Instance Method Details

#debug?Boolean

Returns Whether this configuration is configured for debugging.

Returns:

  • (Boolean)

    Whether this configuration is configured for debugging.



79
80
81
82
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 79

def debug?
  gcc_preprocessor_definitions = resolve_build_setting('GCC_PREPROCESSOR_DEFINITIONS')
  gcc_preprocessor_definitions && gcc_preprocessor_definitions.include?('DEBUG=1')
end

#pretty_printHash{String => Hash}

Returns A hash suitable to display the object to the user.

Returns:

  • (Hash{String => Hash})

    A hash suitable to display the object to the user.



52
53
54
55
56
57
58
59
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 52

def pretty_print
  data = {}
  data['Build Settings'] = sorted_build_settings
  if base_configuration_reference
    data['Base Configuration'] = base_configuration_reference.pretty_print
  end
  { name => data }
end

#resolve_build_setting(key, root_target = nil, previous_key = nil) ⇒ String

Gets the value for the given build setting considering any configuration file present and resolving inheritance between them. It also takes in consideration environment variables.

Parameters:

  • key (String)

    the key of the build setting.

  • root_target (PBXNativeTarget) (defaults to: nil)

    use this to resolve complete recursion between project and targets.

  • previous_key (String) (defaults to: nil)

    use this to resolve complete recursion between different build settings.

Returns:

  • (String)

    The value of the build setting



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 109

def resolve_build_setting(key, root_target = nil, previous_key = nil)
  setting = build_settings[key]
  setting = resolve_variable_substitution(key, setting, root_target, previous_key)

  config_setting = config[key]
  config_setting = resolve_variable_substitution(key, config_setting, root_target, previous_key)

  project_setting = project.build_configuration_list[name]
  project_setting = nil if equal?(project_setting)
  project_setting &&= project_setting.resolve_build_setting(key, root_target)

  defaults = {
    'CONFIGURATION' => name,
    'SRCROOT' => project.project_dir.to_s,
  }

  # if previous_key is nil, it means that we're back at the first call, so we can replace our sentinel string
  # used to prevent recursion with nil
  if previous_key.nil? && setting == MUTUAL_RECURSION_SENTINEL
    setting = nil
  end

  [defaults[key], project_setting, config_setting, setting, ENV[key]].compact.reduce(nil) do |inherited, value|
    expand_build_setting(value, inherited)
  end
end

#sort(_options = nil) ⇒ void

This method returns an undefined value.

Sorts the build settings. Valid only in Ruby > 1.9.2 because in previous versions the hash are not sorted.



72
73
74
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 72

def sort(_options = nil)
  self.build_settings = sorted_build_settings
end

#to_hash_as(method = :to_hash) ⇒ Object



61
62
63
64
65
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 61

def to_hash_as(method = :to_hash)
  super.tap do |hash|
    normalize_array_settings(hash['buildSettings'])
  end
end

#typeSymbol

Returns The symbolic type of this configuration, either ‘:debug` or `:release`.

Returns:

  • (Symbol)

    The symbolic type of this configuration, either ‘:debug` or `:release`.



87
88
89
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 87

def type
  debug? ? :debug : :release
end