xUnique icon indicating copy to clipboard operation
xUnique copied to clipboard

Properly handle missing fields

Open tcamin opened this issue 6 years ago • 5 comments

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.

tcamin avatar Feb 12 '19 15:02 tcamin

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

truebit avatar Feb 13 '19 09:02 truebit

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?

truebit avatar Feb 13 '19 09:02 truebit

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

tcamin avatar Feb 13 '19 10:02 tcamin

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 avatar Feb 15 '19 05:02 truebit

See comment in https://github.com/truebit/xUnique/issues/54#issuecomment-842820571

truebit avatar May 18 '21 04:05 truebit