truebit / xUnique

merge Xcode project file is so easy
https://fclef.wordpress.com
Other
1.5k stars 118 forks source link

Properly handle missing fields #49

Open tcamin opened 5 years ago

tcamin commented 5 years ago

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.

truebit commented 5 years ago

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

truebit commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 3 years ago

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