Skip to content

Fix structured-swift5 template when having the Type keyword in a string #1131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

qeude
Copy link

@qeude qeude commented Jul 12, 2024

  • I've started my branch from the develop branch (gitflow)
    • And I've selected develop as the "base" branch for this Pull Request I'm about to create
  • I've added an entry in the CHANGELOG.md file to explain my changes and credit myself
    (or added #trivial to the PR title if I think it doesn't warrant a mention in the CHANGELOG)
    • Add the entry in the appropriate section (Bug Fix / New Feature / Breaking Change / Internal Change)
    • Add a period and 2 spaces at the end of your short entry description
    • Add links to your GitHub profile to credit yourself and to the related PR and issue after your description

👋 Hey,

I was using SwiftGen for strings and I realized that there is a bug when having a string key containing type as a keyword such as this one dashboard.item.type.item. It creates a enum `Type` but for some reason that seems to come from a Swift bug, it's not usable with L10n.Dashboard.Item.`Type`.item as it ends up with a compiler error.

To fix that, I added a condition in the structured-swift5.stencil so the type keyword is handled as a number would be. That way we would have enum _Type instead which works as expected. With this fix, we would have to use the previous example this way L10n.Dashboard.Item._Type.item.

I know this might not seem like the best solution, but as it seems to be a Swift bug, I don't think we have another option.

@qeude qeude marked this pull request as ready for review July 12, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant