question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Missing support for handling productRef file references

See original GitHub issue

Describe 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

  1. pbxproj version used: latest code from master
  2. python version used: 3.7.6
  3. Xcode version used: 11.5

To Reproduce Steps to reproduce the behavior:

  1. Add a Swift Package to your project
  2. Add the framework to the targets frameworks area
  3. 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:open
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kronenthalercommented, Apr 15, 2021

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 the fileRef but a productRef 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!

0reactions
imeteoracommented, Nov 25, 2021

@kronenthaler It looks like fileRef equals to get_id(). Am I right?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found