Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle missing fields #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tcamin
Copy link

@tcamin tcamin commented Feb 12, 2019

CocoaPods 1.6 is writing a new PBXAggregateTarget section which contains node without productName key. As a result running xUnique against the Pods.xcodeproj resulted in the following error:

  File "build/bdist.macosx-10.12-intel/egg/xUnique.py", line 140, in __set_to_result
KeyError: u'productName'

The fix modifies the __set_to_result method making it (naively) resilient to the missing key.

This became an issue with CocoaPods 1.6 generated Pods.xcodeproj
@truebit
Copy link
Owner

truebit commented Feb 13, 2019

Thanks for the PR.
I saw the productName related code added in #10 .
Could you please test if this breaks fix in #10

@truebit
Copy link
Owner

truebit commented Feb 13, 2019

it seems the sample file in #10 all contains productName, could you please try to construct a valid project file with multiple PBXAggregateTarget items that contains the possibility of absense of "name" and/or "productName" to see if it works?

@tcamin
Copy link
Author

tcamin commented Feb 13, 2019

The missing productName key is only in the aggregateTargets that were added to the Pods.xcodeproj/project.pbxproj by CocoaPods 1.6.

Our project's pbxproj contains targets with productName and name and everything seems to work even after the fix. I'm don't know how to test the absence of name if not by manually removing it from the file and running xunique again which still works

@truebit
Copy link
Owner

truebit commented Feb 15, 2019

You changed base method of __set_to_result, this is used in all types of PBX items. And productName and name for PBXAggregateTarget is to make the generated item unique.
As project files varies huge, we could only change specific spot to not break down others.

I prefer only change the logic around line 338.
Such like trying to get productName, if return None, change it to isa type

@truebit
Copy link
Owner

truebit commented May 18, 2021

See comment in #54 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants