Class: Xcodeproj::Project::Object::XCBuildConfiguration
- Inherits:
-
Object
- Object
- Xcodeproj::Project::Object::XCBuildConfiguration
- Defined in:
- lib/kintsugi/xcodeproj_extensions.rb
Overview
Extends ‘XCBuildConfiguration` to convert array settings (which might be either array or string) to actual arrays in `to_tree_hash` so diffs are always between arrays. This means that if the values in both `ours` and `theirs` are different strings, we will know to solve the conflict into an array containing both strings. Code was mostly copied from github.com/CocoaPods/Xcodeproj/blob/master/lib/xcodeproj/project/object/build_configuration.rb#L211
Constant Summary collapse
- @@old_to_tree_hash =
instance_method(:to_tree_hash)
Instance Method Summary collapse
- #convert_array_settings_to_arrays(settings) ⇒ Object
- #split_string_setting_into_array(string) ⇒ Object
- #to_tree_hash ⇒ Object
Instance Method Details
#convert_array_settings_to_arrays(settings) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/kintsugi/xcodeproj_extensions.rb', line 95 def convert_array_settings_to_arrays(settings) return unless settings array_settings = BuildSettingsArraySettingsByObjectVersion[project.object_version] settings.each_key do |key| value = settings[key] next unless value.is_a?(String) stripped_key = key.sub(/\[[^\]]+\]$/, '') next unless array_settings.include?(stripped_key) array_value = split_string_setting_into_array(value) settings[key] = array_value end end |
#split_string_setting_into_array(string) ⇒ Object
112 113 114 |
# File 'lib/kintsugi/xcodeproj_extensions.rb', line 112 def split_string_setting_into_array(string) string.scan(/ *((['"]?).*?[^\\]\2)(?=( |\z))/).map(&:first) end |
#to_tree_hash ⇒ Object
89 90 91 92 93 |
# File 'lib/kintsugi/xcodeproj_extensions.rb', line 89 def to_tree_hash @@old_to_tree_hash.bind(self).call.tap do |hash| convert_array_settings_to_arrays(hash['buildSettings']) end end |