diff --git a/lib/xcodeproj/project/object/reference_proxy.rb b/lib/xcodeproj/project/object/reference_proxy.rb index 48aedbf5..08a369a7 100644 --- a/lib/xcodeproj/project/object/reference_proxy.rb +++ b/lib/xcodeproj/project/object/reference_proxy.rb @@ -61,6 +61,25 @@ def display_name return path if path super end + + # @return [Array] 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 diff --git a/spec/project/object/reference_proxy_spec.rb b/spec/project/object/reference_proxy_spec.rb index 139f1f99..810a2a45 100644 --- a/spec/project/object/reference_proxy_spec.rb +++ b/spec/project/object/reference_proxy_spec.rb @@ -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