Method: Xcodeproj::Config#merge!

Defined in:
lib/xcodeproj/config.rb

#merge!(xcconfig) ⇒ void Also known as: <<

TODO:

The logic to normalize an hash should be extracted and the initializer should not call this method.

Note:

If a key in the given hash already exists in the internal data then its value is appended.

This method returns an undefined value.

Merges the given xcconfig representation in the receiver.

Examples:


config = Config.new('PODS_ROOT' => '"$(SRCROOT)/Pods"', 'OTHER_LDFLAGS' => '-lxml2')
config.merge!('OTHER_LDFLAGS' => '-lz', 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers"')
config.to_hash # => { 'PODS_ROOT' => '"$(SRCROOT)/Pods"', 'OTHER_LDFLAGS' => '-lxml2 -lz', 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers"' }

Parameters:

  • config (Hash, Config)

    The xcconfig representation to merge.



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/xcodeproj/config.rb', line 216

def merge!(xcconfig)
  if xcconfig.is_a? Config
    merge_attributes!(xcconfig.attributes)
    other_linker_flags.keys.each do |key|
      other_linker_flags[key].merge(xcconfig.other_linker_flags[key])
    end
  else
    merge_attributes!(xcconfig.to_hash)
    if flags = attributes.delete('OTHER_LDFLAGS')
      flags_by_key = OtherLinkerFlagsParser.parse(flags)
      other_linker_flags.keys.each do |key|
        other_linker_flags[key].merge(flags_by_key[key])
      end
    end
  end
end