xUnique
xUnique copied to clipboard
Properly handle missing fields
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.
Thanks for the PR.
I saw the productName
related code added in #10 .
Could you please test if this breaks fix in #10
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?
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
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
See comment in https://github.com/truebit/xUnique/issues/54#issuecomment-842820571