[BUG] Missing support for handling productRef file references
See original GitHub issueDescribe the bug When using Swift Packages in a project, running this tool crashes due to the library being unsure of how to handle productRef file references. Below is an example line from a .pbxproj file that contains Swift Packages:
58AFD9DF24D2077900331519 /* Core in Frameworks */ = {isa = PBXBuildFile; productRef = 58AFD9DE24D2077900331519 /* Core */; };
And here is the trace error:
Traceback (most recent call last):
File "modpbx.py", line 57, in <module>
resultClasses = project.remove_group_by_id(classesGroup.get_id(), True)
File "/usr/local/lib/python3.7/site-packages/pbxproj-2.9.0-py3.7.egg/pbxproj/pbxextensions/ProjectGroups.py", line 65, in remove_group_by_id
File "/usr/local/lib/python3.7/site-packages/pbxproj-2.9.0-py3.7.egg/pbxproj/pbxextensions/ProjectGroups.py", line 70, in remove_group_by_id
File "/usr/local/lib/python3.7/site-packages/pbxproj-2.9.0-py3.7.egg/pbxproj/pbxextensions/ProjectFiles.py", line 317, in remove_file_by_id
AttributeError: 'PBXBuildFile' object has no attribute 'fileRef'
System information
- pbxproj version used: latest code from master
- python version used: 3.7.6
- Xcode version used: 11.5
To Reproduce Steps to reproduce the behavior:
- Add a Swift Package to your project
- Add the framework to the targets frameworks area
- Run the following script:
#! /usr/bin/env python3
import os
from pbxproj import XcodeProject
from pbxproj.pbxextensions.ProjectFiles import *
from pbxproj.pbxextensions.ProjectFiles import FileOptions
ProjectFiles._FILE_TYPES[u'.icalls'] = (u'library.icalls', u'PBXResourcesBuildPhase')
del ProjectFiles._FILE_TYPES['.h'] # to prevent header files from being attached to a
project = XcodeProject.load('./App/App.xcodeproj/project.pbxproj')
rootGroup = project._get_parent_group( None )
unityGroup = None
unityGroups = project.get_groups_by_name('Unity', rootGroup)
if unityGroups.__len__() > 0:
unityGroup = unityGroups[0]
classesGroups = project.get_groups_by_name('Classes', unityGroup)
classesGroup = None
if classesGroups.__len__() > 0:
classesGroup = classesGroups[0]
librariesGroups = project.get_groups_by_name('Libraries', unityGroup)
librariesGroup = None
if librariesGroups.__len__() > 0:
librariesGroup = librariesGroups[0]
if classesGroup is not None:
resultClasses = project.remove_group_by_id(classesGroup.get_id(), True)
Expected behavior Remove the specified groups.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Troubleshoot broken references - Visual Studio - Microsoft Learn
Learn how to troubleshoot broken references that might be caused by something other than your application's inability to find the referenced ...
Read more >Bug: Can't edit Missing Reference in Joint dialog - Autodesk ...
Currently any seemingly minor change in an external linked file breaks joints. Once broken, the joint can't be repaired. User should be able...
Read more >Xcode 13 "Missing package product"… - Apple Developer
I removed their reference and added them back and the build started to work again. The delete + re-add of the package references...
Read more >Bug - Prefabs randomly losing references throughout our project
Over the past few months, my team has been experiencing an annoying problem with prefabs: Suddenly our game is broken and developers need...
Read more >Capture and read bug reports - Android Developers
A bug report contains device logs, stack traces, and other diagnostic ... file system into the zip file under the FS folder so...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @kowaalczyk for the detailed info. This should help to investigate the issue further.
I don’t think that simply wrapping the breaking call with a
hasattr
function will solve the underlying issue. That some buildFile no don’t have thefileRef
but aproductRef
and we should be able to deal with them or at least be able to differenciate the usages and implications of it.Good to know that
force=True
help you out, that might give me extra pointers!@kronenthaler It looks like
fileRef
equals toget_id()
. Am I right?