kronenthaler / mod-pbxproj

A python module to manipulate XCode projects
MIT License
1.2k stars 294 forks source link

[BUG] Exception is thrown when finding `productRef` instead of `fileRef` #352

Closed OmarIthawi closed 2 months ago

OmarIthawi commented 2 months ago

Describe the bug

Exception is thrown when finding productRef instead of fileRef.

BAF0D4CB2AD6AE14007AC334 /* FacebookLogin in Frameworks */ = {isa = PBXBuildFile; productRef = BAF0D4CA2AD6AE14007AC334 /* FacebookLogin */; };

Exception is thrown when trying to remove unrelated files:

Error: An unexpected error occurred in clean_translation_files: 'PBXBuildFile' object has no attribute 'fileRef'
Traceback (most recent call last):
  File "/home/omar/work/openedx/openedx-app-ios/i18n_scripts/translation.py", line 394, in <module>
    main()
  File "/home/omar/work/openedx/openedx-app-ios/i18n_scripts/translation.py", line 390, in main
    clean_translation_files()
  File "/home/omar/work/openedx/openedx-app-ios/i18n_scripts/translation.py", line 335, in clean_translation_files
    xcode_project.remove_files_by_path(file_ref.path, tree=LOCALIZABLE_FILES_TREE)
  File "/home/omar/.virtualenvs/openedx-app-ios/lib/python3.10/site-packages/pbxproj/pbxextensions/ProjectFiles.py", line 366, in remove_files_by_path
    if self.remove_file_by_id(file_ref.get_id(), target_name=target_name):
  File "/home/omar/.virtualenvs/openedx-app-ios/lib/python3.10/site-packages/pbxproj/pbxextensions/ProjectFiles.py", line 332, in remove_file_by_id
    if build_file.fileRef == file_ref.get_id():
AttributeError: 'PBXBuildFile' object has no attribute 'fileRef'
make: *** [Makefile:3: clean_translations] Error 1

System information

  1. pbxproj version used: 4.1.0
  2. python version used: 3.10.12
  3. Xcode version used: I don't know, I use the version on https://github.com/openedx/openedx-app-ios/blob/b2539a6f0ee00a06879f3820d438430a4346363e/Core/Core.xcodeproj/project.pbxproj#L1-L8 and I have no XCode on my Linux machine

To Reproduce Steps to reproduce the behavior:

TBD: Add more details here

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior The file is added despite productRef exists somewhere else.

Screenshots None.

Additional context We're trying to add generated files, and XCode doesn't cooperate without mod-pbxproj help.

Related issues