If you're migrating from SwiftGenKit 1.x to SwiftGenKit 2.0 — which is the case if you are migrating from SwiftGen 4.x to SwiftGen 5.0 — then you should be aware of the following changes in variable names generated in the output context by SwiftGenKit, and adapt your custom templates accordingly to change the name of the variables you use.
As a reminder, you can find all the documentation for the context structures provided as variables to your templates in the Documentation folder of this repository — one MarkDown file for each SwiftGen subcommand / SwiftGenKit parser.
One common changes across all templates is that the enumName
variable (or sceneEnumName
& segueEnumName
for storyboards) have been replaced by their param.enumName
counterparts. Those are variables provided by the user via the --param enumName=…
flag during SwiftGen's command line invocation.
This means that you are now also responsible for providing a default value for those param.enumName
if you use them, in case the user didn't provide the --param enumName=…
flag at all. You can use that with Stencil's default
filter, e.g. enum {{param.enumName|default:"Assets"}}
You can also take advantage of that new --param
feature to make your own templates more customizable, by allowing users to provide arbitrary values via the command line, e.g. using {{param.foo|default:"Foo"}}
and {{param.bar|default:"-"}}
in your templates to let users provide custom values using --param foo=MyFoo --param bar=_
. Just don't forget to document the available params somewhere to let the users of your templates know about those.
📖 see the full context structure in the documentation here.
enumName
has been replaced byparam.enumName
— see above.colors
has been replaced by thepalettes
array, each entry having aname
and acolors
property.- for each
color
:rgb
andrgba
have been removed, as they can be composed from the other components (e.g.#{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}
).
📖 see the full context structure in the documentation here.
enumName
has been replaced byparam.enumName
— see above.- for each
font
:fontName
has been replaced by thename
property.
📖 see the full context structure in the documentation here.
enumName
has been replaced byparam.enumName
— see above.images
is deprecated. The new root key is namedcatalogs
and contains the structured information.
📖 see the full context structure in the documentation here.
extraImports
has been renamedmodules
(see SwiftGen/SwftGen#243)sceneEnumName
has been replaced byparam.sceneEnumName
— see above.segueEnumName
has been replaced byparam.segueEnumName
— see above.- for each
scene
:isBaseViewController
has been removed. You can replace it with a test forbaseType == "ViewController"
as Stencil now implements the==
test operator.
📖 see the full context structure in the documentation here.
enumName
has been replaced byparam.enumName
— see above.strings
andstructuredStrings
have been replaced by thetables
array, where each table has a structuredlevels
property.tableName
has been superseded bytables
array, where each table has aname
property.- for each
level
:subenums
has been renamed tochildren
.
- for each
string
:keytail
has been renamed toname
.- the
params
structure with thenames
,typednames
,types
,count
anddeclarations
arrays have been removed. These have been replaced bytypes
which is an array of types. The previous variables can now be reconstructed using template tags now that Stencil has become more powerful.
Previously the parser context generation method (stencilContext()
) accepted parameters such as enumName
, this has been removed in favor of the --param
system.
Templates will automatically receive a param
object with parameters from the CLI invocation, and should provide default values in case no value was present in the invocation.