Module: Xcode::ConfigurationOwner

Defined in:
lib/xcode/configuration_owner.rb

Instance Method Summary collapse

Instance Method Details

#config(name) {|config| ... } ⇒ BuildConfiguration

Note:

an exception is raised if no configuration matches the specified name.

Return a specific build configuration.

Parameters:

  • name (String)

    of a configuration to return

Yields:

Returns:

  • (BuildConfiguration)

    a specific build configuration that matches the specified name.



26
27
28
29
30
31
# File 'lib/xcode/configuration_owner.rb', line 26

def config(name)
  config = configs.select {|config| config.name == name.to_s }.first
  raise "No such config #{name}, available configs are #{configs.map {|c| c.name}.join(', ')}" if config.nil?
  yield config if block_given?
  config
end

#configsArray<BuildConfiguration>

Returns the configurations that this target or project supports. These are generally ‘Debug’ or ‘Release’ but may be custom created configurations.

Returns:

  • (Array<BuildConfiguration>)

    the configurations that this target or project supports. These are generally ‘Debug’ or ‘Release’ but may be custom created configurations.



9
10
11
12
13
14
# File 'lib/xcode/configuration_owner.rb', line 9

def configs
  build_configuration_list.build_configurations.map do |config|
    config.target = self
    config
  end
end

#create_configuration(name) ⇒ BuildConfiguration

Create a configuration for the target or project.

Examples:

creating a new ‘App Store Submission’ configuration for a project


project.create_config 'App Store Submission' # => Configuration

creating a new ‘Ad Hoc’ configuration for a target


target.create_config 'Ad Hoc' do |config|
  # configuration the new debug config.
end

Parameters:

  • name (String)

    of the configuration to create

Returns:

  • (BuildConfiguration)

    that is created



49
50
51
52
53
54
55
56
57
# File 'lib/xcode/configuration_owner.rb', line 49

def create_configuration(name)
  # To create a configuration, we need to create or retrieve the configuration list
  
  created_config = build_configuration_list.create_config(name) do |config|
    yield config if block_given?
  end
  
  created_config
end

#create_configurations(*configuration_names) ⇒ Object

Create multiple configurations for a target or project.

Examples:

creating ‘Release’ and ‘Debug for a new target


new_target = project.create_target 'UniversalBinary'
new_target.create_configurations 'Debug', 'Release' do |config|
  # set up the configurations
end

Parameters:

  • configuration_names (String, Array<String>)

    the names of the configurations to create.



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/xcode/configuration_owner.rb', line 72

def create_configurations(*configuration_names)
  
  configuration_names.compact.flatten.map do |config_name|
    created_config = create_configuration config_name do |config|
      yield config if block_given?
    end
    
    created_config.save!
  end
  
end