Skip to content

Allow custom "context" values in ResourceSynthesizer Stencil templates #7747

@stefanomondino

Description

@stefanomondino

Why is this needed?

Stencil templates allows resolution of custom parameters of any kind, and many of them are already passed from Tuist via SwiftGen when using ResourceSynthesizers.
However, I've found the need of having some layer of customization in either default Tuist templates and custom ones

Example: the Files template takes an accessModifier (public or implicitly internal when omitted) that cannot be set anywhere in any ProjectDescription. This and other default parameters are hardcoded at the end of this generator

This - in my opinion - is a limit to a feature that can help developers writing better custom architectures for their apps.

Steps to address the need

We should declare some Context object (I'd say a dictionary similar to the ones in use with plist, build settings and entitlements) that can take arbitrary parameters that will be passed down until the SwiftGenKit integration.

In ProjectDescription.ResourceSynthesizer we should add this Context parameter to every existing method, defaulting to an empty one when not needed.

Every in-between object should be changed accordingly.

When merging the customized Context with the default Tuist one, the customized values should overwrite the defaults.

Nothing should change for anyone already using synthesizers.

We should also add a new fixture that test this new feature OR change the existing one for resource synthesizers to be enriched with this new context.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions