From f535adad69454c8cb0bf8854b68e29c79fcdedde Mon Sep 17 00:00:00 2001 From: MSandel Date: Wed, 23 Dec 2020 23:19:25 -0500 Subject: [PATCH 1/2] Adds function to remove file references from target - Issue 523 --- lib/xcodeproj/project/object/native_target.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/xcodeproj/project/object/native_target.rb b/lib/xcodeproj/project/object/native_target.rb index b9d36641f..41662c2da 100644 --- a/lib/xcodeproj/project/object/native_target.rb +++ b/lib/xcodeproj/project/object/native_target.rb @@ -536,6 +536,21 @@ def add_file_references(file_references, compiler_flags = {}) end end + # Removes source files from the target. + # + # @param [Array] file_references + # the files references of the source files that should be removed + # from the target. + # + def remove_file_references(file_references) + file_references.map do |file| + extension = File.extname(file.path).downcase + header_extensions = Constants::HEADER_FILES_EXTENSIONS + is_header_phase = header_extensions.include?(extension) + phase = is_header_phase ? headers_build_phase : source_build_phase + phase.remove_file_reference(file) + end + # Adds resource files to the resources build phase of the target. # # @param [Array] resource_file_references From 336754522e38920d02545de1bc05fac6d70a3cfc Mon Sep 17 00:00:00 2001 From: MSandel Date: Wed, 23 Dec 2020 23:23:19 -0500 Subject: [PATCH 2/2] Adds accidentally removed end :) --- lib/xcodeproj/project/object/native_target.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/xcodeproj/project/object/native_target.rb b/lib/xcodeproj/project/object/native_target.rb index 41662c2da..a8b4f9234 100644 --- a/lib/xcodeproj/project/object/native_target.rb +++ b/lib/xcodeproj/project/object/native_target.rb @@ -550,6 +550,7 @@ def remove_file_references(file_references) phase = is_header_phase ? headers_build_phase : source_build_phase phase.remove_file_reference(file) end + end # Adds resource files to the resources build phase of the target. #