Skip to content

Commit

Permalink
fix: support productRef when removing files (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi authored Jun 26, 2024
1 parent abc9015 commit 78e45a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pbxproj/pbxextensions/ProjectFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def remove_file_by_id(self, file_id, target_name=None):
for build_file_id in filter(lambda x: x in self.objects, build_phase.files):
build_file = self.objects[build_file_id]

if build_file.fileRef == file_ref.get_id():
if hasattr(build_file, 'fileRef') and build_file.fileRef == file_ref.get_id():
# remove the build file from the phase
build_phase.remove_build_file(build_file)

Expand All @@ -355,7 +355,11 @@ def remove_file_by_id(self, file_id, target_name=None):
target.remove_build_phase(build_phase)

# remove it iff it's removed from all targets or no build file reference it
if len([1 for x in self.objects.get_objects_in_section('PBXBuildFile') if x.fileRef == file_ref.get_id()]) != 0:
if len([
True
for x in self.objects.get_objects_in_section('PBXBuildFile')
if hasattr(x, 'fileRef') == file_ref.get_id()
]) != 0:
return True

# remove the file from any groups if there is no reference from any target
Expand Down

0 comments on commit 78e45a5

Please sign in to comment.