Class: Xcodeproj::Project::Object::XCConfigurationList

Inherits:
AbstractObject
  • Object
show all
Defined in:
lib/xcodeproj/project/object/configuration_list.rb

Overview

The primary purpose of this class is to maintain a collection of related build configurations of a PBXProject or a PBXNativeTarget.

Attributes collapse

Attributes inherited from AbstractObject

#isa, #project, #uuid

Attributes collapse

Helpers collapse

Methods inherited from AbstractObject

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

Instance Attribute Details

#default_configuration_is_visibleString

Returns whether the default configuration is visible. Usually `0`. The purpose of this flag and how Xcode displays it in the UI is unknown.

Returns:

  • (String)

    whether the default configuration is visible. Usually `0`. The purpose of this flag and how Xcode displays it in the UI is unknown.


14
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 14

attribute :default_configuration_is_visible, String, '0'

#default_configuration_nameString

Returns the name of the default configuration. Usually `Release`. Xcode exposes this attribute as the configuration for the command line tools and only allows to set it at the project level.

Returns:

  • (String)

    the name of the default configuration. Usually `Release`. Xcode exposes this attribute as the configuration for the command line tools and only allows to set it at the project level.


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

attribute :default_configuration_name, String, 'Release'

Instance Method Details

#[](name) ⇒ XCBuildConfiguration, Nil

Returns the build configuration with the given name.

Parameters:

  • name (String)

    The name of the build configuration.

Returns:

  • (XCBuildConfiguration)

    The build configuration.

  • (Nil)

    If not build configuration with the given name is found.


41
42
43
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 41

def [](name)
  build_configurations.find { |bc| bc.name == name }
end

#ascii_plist_annotationObject

———————————————————————#


107
108
109
110
111
112
113
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 107

def ascii_plist_annotation
  if target.nil?
    ' Build configuration list for <deleted target> '
  else
    " Build configuration list for #{target.isa} \"#{target}\" "
  end
end

#build_configurationsObjectList<XCBuildConfiguration>

Returns the build configurations of the target.

Returns:


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

has_many :build_configurations, XCBuildConfiguration

#build_settings(build_configuration_name) ⇒ Hash {String=>String}

Returns the build settings of the build configuration with the given name.

Parameters:

  • build_configuration_name (String)

    The name of the build configuration.

Returns:

  • (Hash {String=>String})

    the build settings


53
54
55
56
57
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 53

def build_settings(build_configuration_name)
  if config = self[build_configuration_name]
    config.build_settings
  end
end

#get_setting(key, resolve_against_xcconfig = false, root_target = nil) ⇒ Hash{String => String}

Gets the value for the given build setting in all the build configurations.

Parameters:

  • key (String)

    the key of the build setting.

  • resolve_against_xcconfig (Bool) (defaults to: false)

    wether the retrieved setting should take in consideration any configuration file present.

  • root_target (PBXNativeTarget) (defaults to: nil)

    use this to resolve complete recursion between project and targets

Returns:

  • (Hash{String => String})

    The value of the build setting grouped by the name of the build configuration.


75
76
77
78
79
80
81
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 75

def get_setting(key, resolve_against_xcconfig = false, root_target = nil)
  result = {}
  build_configurations.each do |bc|
    result[bc.name] = resolve_against_xcconfig ? bc.resolve_build_setting(key, root_target) : bc.build_settings[key]
  end
  result
end

#set_setting(key, value) ⇒ void

This method returns an undefined value.

Sets the given value for the build setting associated with the given key across all the build configurations.

Parameters:

  • key (String)

    the key of the build setting.

  • value (String)

    the value for the build setting.


94
95
96
97
98
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 94

def set_setting(key, value)
  build_configurations.each do |bc|
    bc.build_settings[key] = value
  end
end

#targetObject


100
101
102
103
# File 'lib/xcodeproj/project/object/configuration_list.rb', line 100

def target
  return project.root_object if project.build_configuration_list.uuid == uuid
  project.targets.find { |t| t.build_configuration_list.uuid == uuid }
end