Skip to content

Commit

Permalink
reference_proxy: Remove build files that refer to it when removed.
Browse files Browse the repository at this point in the history
A reference proxy might have build files that refer to it, and as
mentioned in the previous commit, they don't have any meaning without
it. Therefore they are removed when the reference proxy is removed.
  • Loading branch information
byohay committed Oct 24, 2021
1 parent 943852a commit 7450dc3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/xcodeproj/project/object/reference_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ def display_name
return path if path
super
end

# @return [Array<PBXBuildFile>] the build files associated with the
# current reference proxy.
#
def build_files
referrers.grep(PBXBuildFile)
end

# In addition to removing the reference proxy, this will also remove any
# items related to this reference.
#
# @see AbstractObject#remove_from_project
#
# @return [void]
#
def remove_from_project
build_files.each(&:remove_from_project)
super
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/project/object/reference_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@ module ProjectSpecs
@proxy.path = 'Path/To/Proxy'
@proxy.display_name.should == 'Path/To/Proxy'
end

it 'removes the build files when removing the reference proxy' do
@target = @project.new_target(:static_library, 'Pods', :ios)
@target.build_phases[0].add_file_reference(@proxy)

@proxy.remove_from_project
@target.build_phases[0].files.should.be.empty
end
end
end

0 comments on commit 7450dc3

Please sign in to comment.