diff --git a/kintsugi.gemspec b/kintsugi.gemspec index dc676fa..89c89d4 100644 --- a/kintsugi.gemspec +++ b/kintsugi.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "tty-prompt", "~> 0" - spec.add_dependency "xcodeproj", ">= 1.19.0", "<= 1.27.0" + spec.add_dependency "xcodeproj", ">= 1.26.0", "<= 1.27.0" spec.add_development_dependency "git", "~> 1.11" spec.add_development_dependency "rake", "~> 13.0" diff --git a/lib/kintsugi/apply_change_to_project.rb b/lib/kintsugi/apply_change_to_project.rb index 46905d6..3445954 100644 --- a/lib/kintsugi/apply_change_to_project.rb +++ b/lib/kintsugi/apply_change_to_project.rb @@ -107,7 +107,7 @@ def flatten_change(change, path) def apply_group_additions(project, additions, force_create_containing_group: false) additions.each do |change, path| - next unless %w[PBXGroup PBXVariantGroup].include?(change["isa"]) + next unless %w[PBXGroup PBXVariantGroup PBXFileSystemSynchronizedRootGroup].include?(change["isa"]) group_type = Module.const_get("Xcodeproj::Project::#{change["isa"]}") containing_group = project.group_or_file_at_path(path) @@ -652,6 +652,8 @@ def add_child_to_component(component, change, change_path) add_file_reference(component, change, change_path) when "PBXGroup" add_group(component, change, change_path) + when "PBXFileSystemSynchronizedRootGroup" + add_file_system_synchronized_root_group(component, change, change_path) when "PBXContainerItemProxy" add_container_item_proxy(component, change, change_path) when "PBXTargetDependency" @@ -1015,6 +1017,22 @@ def add_group(containing_component, change, change_path) end end + def add_file_system_synchronized_root_group(containing_component, change, change_path) + case containing_component + when Xcodeproj::Project::ObjectDictionary + # It is assumed that an `ObjectDictionary` always represents a project reference. + new_group = containing_component[:project_ref].project.new(Xcodeproj::Project::PBXFileSystemSynchronizedRootGroup) + containing_component[:product_group] = new_group + add_attributes_to_component(new_group, change, change_path) + when Xcodeproj::Project::PBXGroup + # Adding file system synchronized root groups to groups is handled by another part of the code. + else + raise MergeError, "Trying to add file system synchronized root group to an unsupported component type " \ + "#{containing_component.isa}. Change is: #{change}. Change path: " \ + "#{change_path}" + end + end + def add_attributes_to_component(component, change, change_path, ignore_keys: []) change.each do |change_name, change_value| next if (%w[isa displayName] + ignore_keys).include?(change_name)