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.

Yields:



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>



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


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


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