diff --git a/lib/xcodeproj/project/object/group.rb b/lib/xcodeproj/project/object/group.rb index 4888b7df..7571eadd 100644 --- a/lib/xcodeproj/project/object/group.rb +++ b/lib/xcodeproj/project/object/group.rb @@ -448,6 +448,25 @@ def sort(options = nil) result end 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 #-----------------------------------------------------------------------# 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/group_spec.rb b/spec/project/object/group_spec.rb index b3c2b6ca..01f52394 100644 --- a/spec/project/object/group_spec.rb +++ b/spec/project/object/group_spec.rb @@ -352,6 +352,15 @@ module ProjectSpecs end end + it 'removes the build files when removing the group' do + @target = @project.new_target(:static_library, 'Pods', :ios) + build_file = @project.new(Xcodeproj::Project::PBXBuildFile) + build_file.file_ref = @group + @target.build_phases[0].files << build_file + + @group.remove_from_project + @target.build_phases[0].files.should.be.empty + 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