tuist / tuist

Tuist's CLI
https://tuist.io
MIT License
4.57k stars 553 forks source link

Using custom asset template causes `enumName` parameter to be ignored #6845

Open kacper1703 opened 1 week ago

kacper1703 commented 1 week ago

What happened?

I need to use a custom stencil for fonts in my project. However, when the code is generated, the generation command's enumName parameter is ignored and is not passed properly as when using default templates. As I have multiple targets and a shared UI framework in the same project, it causes compiler confusion as to which FontFamily to use.

The custom stencil still has the following code for enum name:

{{accessModifier}} enum {{param.enumName|default:"FontFamily"}} {

Surprisingly, the accessModifier is public, so based on the following template code

{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}

the publicAccess param does seem to be passed into the stencil.

How do we reproduce it?

  1. Create a target called ABC. Run default asset generation. Enum name is ABCFontFamily.
  2. Download the default .stencil file for fonts (from SwiftGen's repository),
  3. Name the file Fonts.stencil and place it in Tuist/ResourceSynthesizers
  4. Run tuist generate
  5. The enumName is ignored and the fonts enum has the default value of FontFamily.

Error log

n/a

macOS version

15.0.1 (24A348)

Tuist version

4.28.1 (Homebrew)

Xcode version

16.0 (16A242d)

pbk20191 commented 2 days ago

makeParam

injects only name, publicAccess, bundle and you can only modify name and bundle. I think you should use name not enumName