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



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

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.



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

attribute :build_settings, Hash, {}

#nameString

Returns the name of the configuration.

Returns:

  • (String)

    the name of the configuration.



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

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.



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

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.



36
37
38
39
40
41
42
43
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 36

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



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 93

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.



56
57
58
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 56

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

#to_hash_as(method = :to_hash) ⇒ Object



45
46
47
48
49
# File 'lib/xcodeproj/project/object/build_configuration.rb', line 45

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.



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

def type
  debug? ? :debug : :release
end