Module: Xcode::Configuration

Defined in:
lib/xcode/configuration.rb,
lib/xcode/configurations/array_property.rb,
lib/xcode/configurations/string_property.rb,
lib/xcode/configurations/boolean_property.rb,
lib/xcode/configurations/key_value_array_property.rb,
lib/xcode/configurations/space_delimited_string_property.rb,
lib/xcode/configurations/targeted_device_family_property.rb

Overview

Projects have a number of build configurations. These configurations are usually the default ‘Debug’ and ‘Release’. However, custom ones can be defined.

Each configuration is defined and then a reference of that configuration is maintained in the Target through the XCConfigurationList.

Examples:

Xcode configuration


E21D8ABB14E0F817002E56AA /* Debug */ = {                     
  isa = XCBuildConfiguration;                                
  buildSettings = {                                          
    "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
    GCC_PRECOMPILE_PREFIX_HEADER = YES;                      
    GCC_PREFIX_HEADER = "newtarget/newtarget-Prefix.pch";    
    INFOPLIST_FILE = "newtarget/newtarget-Info.plist";       
    PRODUCT_NAME = "$(TARGET_NAME)";                         
    WRAPPER_EXTENSION = app;                                 
  };                                                         
  name = Debug;                                              
};                                                           

See Also:

Defined Under Namespace

Modules: ArrayProperty, BooleanProperty, KeyValueArrayProperty, SpaceDelimitedString, StringProperty, TargetedDeviceFamily

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#always_search_user_pathsObject

Build Setting - “ALWAYS_SEARCH_USER_PATHS”



207
# File 'lib/xcode/configuration.rb', line 207

property :always_search_user_paths, "ALWAYS_SEARCH_USER_PATHS", BooleanProperty

#architecturesObject

Build Setting - “ARCHS”



217
# File 'lib/xcode/configuration.rb', line 217

property :architectures, "ARCHS", SpaceDelimitedString

#c_language_standardObject

Build Setting - “GCC_C_LANGUAGE_STANDARD” Usually set to gnu99



202
# File 'lib/xcode/configuration.rb', line 202

property :c_language_standard, "GCC_C_LANGUAGE_STANDARD", StringProperty

#code_sign_identityObject

Build Setting - “CODE_SIGN_IDENTITY



232
# File 'lib/xcode/configuration.rb', line 232

property :code_sign_identity, "CODE_SIGN_IDENTITY[sdk=>iphoneos*]", StringProperty

#copy_phase_stripObject

Build Setting - “COPY_PHASE_STRIP”



248
# File 'lib/xcode/configuration.rb', line 248

property :copy_phase_strip, "COPY_PHASE_STRIP", BooleanProperty

#dead_code_strippingObject

Build Setting - “DEAD_CODE_STRIPPING”



258
# File 'lib/xcode/configuration.rb', line 258

property :dead_code_stripping, "DEAD_CODE_STRIPPING", BooleanProperty

#debug_information_formatObject

Build Setting - “DEBUG_INFORMATION_FORMAT”



263
264
# File 'lib/xcode/configuration.rb', line 263

property :debug_information_format, "DEBUG_INFORMATION_FORMAT", 
EnumerationProperty.new('stabs','dwarf','dwarf-with-dsym')

#enable_objc_exceptionsObject

Build Setting - “GCC_ENABLE_OBJC_EXCEPTIONS”



270
# File 'lib/xcode/configuration.rb', line 270

property :enable_objc_exceptions, "GCC_ENABLE_OBJC_EXCEPTIONS", BooleanProperty

#gcc_versionObject

Build Setting - “GCC_VERSION”



212
# File 'lib/xcode/configuration.rb', line 212

property :gcc_version, "GCC_VERSION", StringProperty

#generate_debugging_symbolsObject

Build Setting - “GCC_GENERATE_DEBUGGING_SYMBOLS”



275
# File 'lib/xcode/configuration.rb', line 275

property :generate_debugging_symbols, "GCC_GENERATE_DEBUGGING_SYMBOLS", BooleanProperty

#info_plist_locationObject

Build Setting - “INFOPLIST_FILE”



177
# File 'lib/xcode/configuration.rb', line 177

property :info_plist_location, "INFOPLIST_FILE", StringProperty

#install_pathObject

Build Setting - “INSTALL_PATH”



295
# File 'lib/xcode/configuration.rb', line 295

property :install_path, "INSTALL_PATH", StringProperty

#iphoneos_deployment_targetObject

TODO:

this should be a numeric scale from 2.0 through 5.0; at the levels specified in the documentation

Build Setting - “IPHONEOS_DEPLOYMENT_TARGET”



243
# File 'lib/xcode/configuration.rb', line 243

property :iphoneos_deployment_target, "IPHONEOS_DEPLOYMENT_TARGET", StringProperty

Build Setting - “LINK_WITH_STANDARD_LIBRARIES”



290
# File 'lib/xcode/configuration.rb', line 290

property :link_with_standard_libraries, "LINK_WITH_STANDARD_LIBRARIES", BooleanProperty

#mach_o_typeObject

Build Setting - “MACH_O_TYPE”



300
301
# File 'lib/xcode/configuration.rb', line 300

property :mach_o_type, "MACH_O_TYPE", 
EnumerationProperty.new('mh_executable', 'mh_bundle', 'mh_object', 'mh_dylib', 'staticlib')

#macosx_deployment_targetObject

Build Setting - “MACOSX_DEPLOYMENT_TARGET”



306
307
# File 'lib/xcode/configuration.rb', line 306

property :macosx_deployment_target, "MACOSX_DEPLOYMENT_TARGET", 
EnumerationProperty.new('10.7','10.6','10.5','10.4','10.3','10.2','10.1')

#other_c_flagsObject

Build Setting - “OTHER_CFLAGS”



197
# File 'lib/xcode/configuration.rb', line 197

property :other_c_flags, "OTHER_CFLAGS", KeyValueArrayProperty

#other_linker_flagsObject

Build Setting - “OTHER_LDFLAGS”



253
# File 'lib/xcode/configuration.rb', line 253

property :other_linker_flags, "OTHER_LDFLAGS", SpaceDelimitedString

#precompile_prefix_headersObject

Build Setting - “GCC_PRECOMPILE_PREFIX_HEADER”



167
# File 'lib/xcode/configuration.rb', line 167

property :precompile_prefix_headers, "GCC_PRECOMPILE_PREFIX_HEADER", BooleanProperty

#prefix_headerObject

Build Setting - “GCC_PREFIX_HEADER”



172
# File 'lib/xcode/configuration.rb', line 172

property :prefix_header, "GCC_PREFIX_HEADER", StringProperty

#product_nameObject

Build Setting - “PRODUCT_NAME”



158
# File 'lib/xcode/configuration.rb', line 158

property :product_name, "PRODUCT_NAME", StringProperty

#sdkrootObject

Build Setting - “SDKROOT”



192
# File 'lib/xcode/configuration.rb', line 192

property :sdkroot, "SDKROOT", StringProperty

#supported_platformsObject

Build Setting - “SUPPORTED_PLATFORMS”



162
# File 'lib/xcode/configuration.rb', line 162

property :supported_platforms, "SUPPORTED_PLATFORMS", SpaceDelimitedString

#targetObject

As configurations are defined within a target, this will return the target that owns this configuration through a build_configuration list.

However, a build configuration list can also be defined at the project level which means target may likely be nil when viewing the configuration of the project.



154
155
156
# File 'lib/xcode/configuration.rb', line 154

def target
  @target
end

#targeted_device_familyObject

Build Setting - “TARGETED_DEVICE_FAMILY”



187
# File 'lib/xcode/configuration.rb', line 187

property :targeted_device_family, "TARGETED_DEVICE_FAMILY", TargetedDeviceFamily

#user_header_search_pathsObject

Build Setting - “USER_HEADER_SEARCH_PATHS”



339
# File 'lib/xcode/configuration.rb', line 339

property :user_header_search_paths, "USER_HEADER_SEARCH_PATHS", SpaceDelimitedString

#valid_architecturesObject

Build Setting - “VALID_ARCHS”



312
# File 'lib/xcode/configuration.rb', line 312

property :valid_architectures, "VALID_ARCHS", SpaceDelimitedString

#validate_productObject

Build Setting - “VALIDATE_PRODUCT”



237
# File 'lib/xcode/configuration.rb', line 237

property :validate_product, "VALIDATE_PRODUCT", BooleanProperty

#warn_64_to_32_bit_conversionObject

Build Setting - “GCC_WARN_64_TO_32_BIT_CONVERSION”



280
# File 'lib/xcode/configuration.rb', line 280

property :warn_64_to_32_bit_conversion, "GCC_WARN_64_TO_32_BIT_CONVERSION", BooleanProperty

#warn_about_missing_prototypesObject

Build Setting - “GCC_WARN_ABOUT_MISSING_PROTOTYPES” Defaults to YES



222
# File 'lib/xcode/configuration.rb', line 222

property :warn_about_missing_prototypes, "GCC_WARN_ABOUT_MISSING_PROTOTYPES", BooleanProperty

#warn_about_missing_protoypesObject

Build Setting - “GCC_WARN_ABOUT_MISSING_PROTOTYPES”



285
# File 'lib/xcode/configuration.rb', line 285

property :warn_about_missing_protoypes, "GCC_WARN_ABOUT_MISSING_PROTOTYPES", BooleanProperty

#warn_about_return_typeObject

Build Setting - “GCC_WARN_ABOUT_MISSING_PROTOTYPES”



227
# File 'lib/xcode/configuration.rb', line 227

property :warn_about_return_type, "GCC_WARN_ABOUT_RETURN_TYPE", BooleanProperty

#wrapper_extensionObject

Build Setting - “WRAPPER_EXTENSION”



182
# File 'lib/xcode/configuration.rb', line 182

property :wrapper_extension, "WRAPPER_EXTENSION", StringProperty

Class Method Details

.default_properties(name) ⇒ Hash

TODO:

remove the name requirement and replace all these configuration settings with the smaller subset. As a lot of these are usually maintained by the project

A large number of these default build settings properties for a configuration are as defined for Xcode 4.2.

Parameters:

  • name (String)

    is used to create the correct prefix header file and info.plist file.

Returns:

  • (Hash)

    properties for a default build configuration



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/xcode/configuration.rb', line 49

def self.default_properties(name)
  { 'isa' => 'XCBuildConfiguration',
    'buildSettings' => {
      "SDKROOT" => "iphoneos",
      "OTHER_CFLAGS" => "-DNS_BLOCK_ASSERTIONS=1",
      "TARGETED_DEVICE_FAMILY" => "1,2",
      "GCC_C_LANGUAGE_STANDARD" => "gnu99",
      "ALWAYS_SEARCH_USER_PATHS" => "NO",
      "GCC_VERSION" => "com.apple.compilers.llvm.clang.1_0",
      "ARCHS" => "$(ARCHS_STANDARD_32_BIT)",
      "GCC_WARN_ABOUT_MISSING_PROTOTYPES" => "YES",
      "GCC_WARN_ABOUT_RETURN_TYPE" => "YES",
      "CODE_SIGN_IDENTITY[sdk=>iphoneos*]" => "iPhone Developer",
      "GCC_PRECOMPILE_PREFIX_HEADER" => "YES",
      "VALIDATE_PRODUCT" => "YES",
      "IPHONEOS_DEPLOYMENT_TARGET" => "5.0",
      "COPY_PHASE_STRIP" => "YES",
      "GCC_PREFIX_HEADER" => "#{name}/#{name}-Prefix.pch",
      "INFOPLIST_FILE" => "#{name}/#{name}-Info.plist",
      "PRODUCT_NAME" => "$(TARGET_NAME)",
      "WRAPPER_EXTENSION" => "app" },
      "name" => name }
end

.property(property_name, setting_name, type) ⇒ Object

This method will define getters/setters mapped to the build configuration.

This allows for dynamic values to be saved and loaded by allowing a parsing process to take place on the loaded value and when saving back to the value.

Parameters:

  • property_name (Symbol)

    the name of the property that is being defined

  • String (String setting_name the configuration value string)

    setting_name the configuration value string

  • type (Types)

    is the class that is used to load and save the value correctly.



84
85
86
87
88
89
90
91
92
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/xcode/configuration.rb', line 84

def self.property(property_name,setting_name,type)
  
  # Define a getter method

  define_method property_name do
    
    # When the build setting is missing from the existing configuration, look
    # for the configuration of the target's project (only if we are currently
    # at the Target level).
    
    if not build_settings.key?(setting_name) and target.is_a?(Target)
      project_config = target.project.global_config(name)
      project_config.send(property_name)
    else
      substitute type.open(build_settings[setting_name])
    end
    
  end

  # Define a setter method
  
  define_method "#{property_name}=" do |value|
    build_settings[setting_name] = unsubstitute(type.save(value))
  end

  # Define an append method
  
  define_method "append_to_#{property_name}" do |value|
    build_settings[setting_name] = unsubstitute type.append(build_settings[setting_name],value)
  end
  
  # Define a environment name method (to return the settings name)
  
  define_method "env_#{property_name}" do
    setting_name
  end
  
  # Define a raw getter
  
  define_method "raw_#{property_name}" do
    build_settings[setting_name]
  end
  
  # Define a raw setter
  
  define_method "raw_#{property_name}=" do |value|
    build_settings[setting_name] = value
  end
  
  
  @setting_name_to_property = {} unless @setting_name_to_property
  @setting_name_to_property[setting_name] = property_name
  
end

.setting_name_to_property(name) ⇒ Object



139
140
141
# File 'lib/xcode/configuration.rb', line 139

def self.setting_name_to_property(name)
  @setting_name_to_property[name]
end

Instance Method Details

#append(name, value) ⇒ Object

Append a value to the the configuration value for the given name

Parameters:

  • name (String)

    of the the configuration setting

  • value (String, Array, Hash)

    the value to store for the specific setting



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/xcode/configuration.rb', line 379

def append(name, value)
  
  if respond_to?(name)
    send("append_to_#{name}",value)
  elsif Configuration.setting_name_to_property(name)
    send("append_to_#{Configuration.setting_name_to_property(name)}",value)
  else

    # @note this will likely raise some errors if trying to append a booleans
    #   to fixnums, strings to booleans, symbols + arrays, etc. but that likely 
    #   means a new property should be defined so that the appending logic
    #   wil behave correctly.
  
    if build_settings[name].is_a?(Array)
      
      # Ensure that we are appending an array to the array; Array() does not
      # work in this case in the event we were to pass in a Hash.
      value = value.is_a?(Array) ? value : [ value ]
      build_settings[name] = build_settings[name] + value.compact
      
    else
      
      # Ensure we handle the cases where a nil value is present that we append
      # correctly to the value. We also need to try and leave intact boolean
      # values which may be stored
      
      value = "" unless value
      build_settings[name] = "" unless build_settings[name]
      
      build_settings[name] = build_settings[name] + value
    end
   
  end
end

#builderBuilder

Create a builder for this given project->target->configuration.

Returns:

  • (Builder)

    this is a builder for the configuration.

See Also:



420
421
422
# File 'lib/xcode/configuration.rb', line 420

def builder
  Xcode::Builder::ProjectTargetConfigBuilder.new(@target, self)
end

#get(name) ⇒ String, ...

Retrieve the configuration value for the given name

Parameters:

  • name (String)

    of the configuration settings to return

Returns:

  • (String, Array, Hash)

    the value stored for the specified configuration



347
348
349
350
351
352
353
354
355
# File 'lib/xcode/configuration.rb', line 347

def get(name)
  if respond_to?(name)
    send(name)
  elsif Configuration.setting_name_to_property(name)
    send Configuration.setting_name_to_property(name)
  else
    build_settings[name]
  end
end

#info_plist {|info| ... } ⇒ Object

Opens the info plist associated with the configuration and allows you to edit the configuration.

Examples:

Editing the configuration


config = Xcode.project('MyProject.xcodeproj').target('Application').config('Debug')
config.info_plist do |plist|
  puts plist.version  # => 1.0
  plist.version = 1.1
  marketing_version = 12.1
end

Yields:

  • (info)

See Also:



329
330
331
332
333
334
# File 'lib/xcode/configuration.rb', line 329

def info_plist
  info = Xcode::InfoPlist.new(self, info_plist_location)  
  yield info if block_given?
  info.save
  info
end

#set(name, value) ⇒ Object

Set the configuration value for the given name

Parameters:

  • name (String)

    of the the configuration setting

  • value (String, Array, Hash)

    the value to store for the specific setting



363
364
365
366
367
368
369
370
371
# File 'lib/xcode/configuration.rb', line 363

def set(name, value)
  if respond_to?(name)
    send("#{name}=",value)
  elsif Configuration.setting_name_to_property(name)
    send("#{Configuration.setting_name_to_property(name)}=",value)
  else
    build_settings[name] = value
  end
end