File tree Expand file tree Collapse file tree 7 files changed +70
-2
lines changed
lib/xcodeproj/project/object Expand file tree Collapse file tree 7 files changed +70
-2
lines changed Original file line number Diff line number Diff line change 2020 [ Zachary Waldowski] ( https://github.com/zwaldowski )
2121 [ #862 ] ( https://github.com/CocoaPods/Xcodeproj/pull/862 )
2222
23+ * Remove build files when underlying file_ref is removed.
24+ [ Ben Yohay] ( https://github.com/byohay )
25+ [ #861 ] ( https://github.com/CocoaPods/Xcodeproj/pull/861 )
26+
2327##### Bug Fixes
2428
2529* Fix undefined method 'downcase' for ` nil `
Original file line number Diff line number Diff line change @@ -313,8 +313,7 @@ def target_dependency_proxies
313313 end
314314
315315 # In addition to removing the file reference, this will also remove any
316- # items related to this reference in case it represents an external
317- # Xcode project.
316+ # items related to this reference.
318317 #
319318 # @see AbstractObject#remove_from_project
320319 #
@@ -327,6 +326,8 @@ def remove_from_project
327326 project_reference [ :product_group ] . remove_from_project
328327 project . root_object . project_references . delete ( project_reference )
329328 end
329+
330+ build_files . each ( &:remove_from_project )
330331 super
331332 end
332333
Original file line number Diff line number Diff line change @@ -448,6 +448,25 @@ def sort(options = nil)
448448 result
449449 end
450450 end
451+
452+ # @return [Array<PBXBuildFile>] the build files associated with the
453+ # current reference proxy.
454+ #
455+ def build_files
456+ referrers . grep ( PBXBuildFile )
457+ end
458+
459+ # In addition to removing the reference proxy, this will also remove any
460+ # items related to this reference.
461+ #
462+ # @see AbstractObject#remove_from_project
463+ #
464+ # @return [void]
465+ #
466+ def remove_from_project
467+ build_files . each ( &:remove_from_project )
468+ super
469+ end
451470 end
452471
453472 #-----------------------------------------------------------------------#
Original file line number Diff line number Diff line change @@ -61,6 +61,25 @@ def display_name
6161 return path if path
6262 super
6363 end
64+
65+ # @return [Array<PBXBuildFile>] the build files associated with the
66+ # current reference proxy.
67+ #
68+ def build_files
69+ referrers . grep ( PBXBuildFile )
70+ end
71+
72+ # In addition to removing the reference proxy, this will also remove any
73+ # items related to this reference.
74+ #
75+ # @see AbstractObject#remove_from_project
76+ #
77+ # @return [void]
78+ #
79+ def remove_from_project
80+ build_files . each ( &:remove_from_project )
81+ super
82+ end
6483 end
6584 end
6685 end
Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ module ProjectSpecs
7575 @file . comments . should == 'This file was automatically generated.'
7676 end
7777
78+ it 'removes the build files when removing the file reference' do
79+ @target = @project . new_target ( :static_library , 'Pods' , :ios )
80+ @target . build_phases [ 0 ] . add_file_reference ( @file )
81+
82+ @file . remove_from_project
83+ @target . build_phases [ 0 ] . files . should . be . empty
84+ end
85+
7886 describe 'concerning proxies' do
7987 it 'returns that it is not a proxy' do
8088 @file . should . not . be . a . proxy
Original file line number Diff line number Diff line change @@ -352,6 +352,15 @@ module ProjectSpecs
352352 end
353353 end
354354
355+ it 'removes the build files when removing the group' do
356+ @target = @project . new_target ( :static_library , 'Pods' , :ios )
357+ build_file = @project . new ( Xcodeproj ::Project ::PBXBuildFile )
358+ build_file . file_ref = @group
359+ @target . build_phases [ 0 ] . files << build_file
360+
361+ @group . remove_from_project
362+ @target . build_phases [ 0 ] . files . should . be . empty
363+ end
355364 #-------------------------------------------------------------------------#
356365 end
357366end
Original file line number Diff line number Diff line change @@ -24,5 +24,13 @@ module ProjectSpecs
2424 @proxy . path = 'Path/To/Proxy'
2525 @proxy . display_name . should == 'Path/To/Proxy'
2626 end
27+
28+ it 'removes the build files when removing the reference proxy' do
29+ @target = @project . new_target ( :static_library , 'Pods' , :ios )
30+ @target . build_phases [ 0 ] . add_file_reference ( @proxy )
31+
32+ @proxy . remove_from_project
33+ @target . build_phases [ 0 ] . files . should . be . empty
34+ end
2735 end
2836end
You can’t perform that action at this time.
0 commit comments