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`).



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

has_one :base_configuration_reference, PBXFileReference

#build_settingsHash

Returns the build settings to use for building the target.

Returns:

  • (Hash)

    the build settings to use for building the target.



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

attribute :build_settings, Hash, {}

#nameString

Returns the name of the Target.

Returns:

  • (String)

    the name of the Target.



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

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.



59
60
61
62
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 59

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.



32
33
34
35
36
37
38
39
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 32

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) ⇒ 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

Returns:

  • (String)

    The value of the build setting



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 86

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

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

  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,
  }

  [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.



52
53
54
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 52

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

#to_hash_as(method = :to_hash) ⇒ Object



41
42
43
44
45
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 41

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`.



67
68
69
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 67

def type
  debug? ? :debug : :release
end