XcodeProj
XcodeProj copied to clipboard
PBXGroup file(named:) API assumes filenames (only) are unique in group
Context 🕵️♀️
PBXGroup contain an array of files. As far as I'm aware, Xcode places very little restriction on what can be placed in a group, and it's up to the user to add files sensibly...
What 🌱
PBXGroup.file(named:) allows finding a file within a group, but using only the filename as the search criteria. This means that if, for example, the group contained two files, with the same name, but different locations, then then API would just return the first:
group
- 1: fileA (path: `foo/bar/fileA`)
- 2: fileA (path: `bar/fileA`)
This API would only ever return 1, even though it's perfectly possible to have duplicate filenames in a group
Proposal 🎉
Add an API that searches instead by the path to files. This correctly identifies files uniquely, and would return the correct file:
group
- 1: fileA (path: `foo/bar/fileA`)
- 2: fileA (path: `bar/fileA`)
- "file with name
fileAand pathfoo/bar/fileA" returns1 - "file with name
fileAand pathbar/fileA" returns2 - "file with name
fileAand path." returnsnil