From 8722e99624c8aebc6ea275d1a11153ee6da0e0c3 Mon Sep 17 00:00:00 2001 From: Ben Yohay Date: Sat, 4 Apr 2020 14:31:29 +0300 Subject: [PATCH] target_dependency: Add target proxy to `to_tree_hash`. The added information helps identifying the correct dependency. --- CHANGELOG.md | 3 ++- .../project/object/target_dependency.rb | 1 + spec/project/object/target_dependency_spec.rb | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0238fef1..57e3f710c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ##### Enhancements -* None. +* target_dependency: Add target proxy to `to_tree_hash`. + [Ben Yohay](https://github.com/byohay) ##### Bug Fixes diff --git a/lib/xcodeproj/project/object/target_dependency.rb b/lib/xcodeproj/project/object/target_dependency.rb index 9c3f69d0e..43f4092b3 100644 --- a/lib/xcodeproj/project/object/target_dependency.rb +++ b/lib/xcodeproj/project/object/target_dependency.rb @@ -73,6 +73,7 @@ def to_tree_hash hash = {} hash['displayName'] = display_name hash['isa'] = isa + hash['targetProxy'] = target_proxy.to_tree_hash hash end diff --git a/spec/project/object/target_dependency_spec.rb b/spec/project/object/target_dependency_spec.rb index 8e5087d00..74c2a294a 100644 --- a/spec/project/object/target_dependency_spec.rb +++ b/spec/project/object/target_dependency_spec.rb @@ -40,6 +40,32 @@ module ProjectSpecs lambda { @target_dependency.sort_recursively }.should.not.raise end + it 'tree hash does not contain target' do + target = @project.new_target(:static, 'Pods', :ios) + @target_dependency.target = target + target.dependencies << @target_dependency + + proxy = @project.new(PBXContainerItemProxy) + proxy.container_portal = @project.root_object.uuid + proxy.remote_info = 'Pods' + proxy.proxy_type = '1' + proxy.remote_global_id_string = target.uuid + @target_dependency.target_proxy = proxy + + @target_dependency.to_tree_hash.should == { + 'displayName' => 'Pods', + 'isa' => 'PBXTargetDependency', + 'targetProxy' => { + 'displayName' => 'ContainerItemProxy', + 'isa' => 'PBXContainerItemProxy', + 'containerPortal' => @project.root_object.uuid, + 'proxyType' => '1', + 'remoteGlobalIDString' => target.uuid, + 'remoteInfo' => 'Pods', + }, + } + end + #----------------------------------------# describe '#display_name' do