yonaskolb / yonaskolb/XcodeGen
Having an empty templateAttributes causes all attributes to be removed.
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 8.8k
- Forks
- 908
- Avg merge
- 17d 14h
- Merged PRs (30d)
- 2
Description
Given the following project.yml, MyTarget will be created with no template attributes. It seems like if anything contains an empty templateAttributes, it all cause all other attributes that may have some from another template to be ignored/removed.
targetTemplates:
SomeTemplate:
templateAttributes:
someAttribute: "Some Value"
targets:
MyTarget:
templates:
- SomeTemplate
templateAttributes:
It's easy enough to work around by adding any attitude to the target.
templateAttributes:
_:
I'd assume xcodegen is trying to merge the dictionaries but the one from the target with no content is possibly being parsed into a string which cant be merged with the existing dictionary. So instead of throwing an error or using the current values in the dictionary, it's returning an empty one.
"By why have an empty templateAttributes in the first place?" you may be asking.
We have some tooling to automatically update the yml files for various reasons. Having the templateAttributes allows us to set where it should appear in the file. If we rely on the scripts to add it when needed, it'd probably be added to either the bottom of the file, or a random location since dictionaries are unordered.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the project.yml example and trace how target and templateAttributes dictionaries are merged during project generation. The fix is done when an empty target-level templateAttributes preserves attributes inherited from SomeTemplate, with a regression test covering this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100