The resourceCount
variable is now deprecated.
Migration Guide
The documents
variable of each "file" is now considered as deprecated, it's replacement is document
. The documents
variable is still available, but will be removed in SwiftGen 7.0.
Initially we provided documents
to keep the (context) data model the same for the JSON, Plist and YAML parsers, even though only YAML files can have multiple documents in one file. We've decided to forgo that approach, as our contexts should match the underlying content.
Migration Guide
The parser will no longer normalize string keys, which can lead to duplicate keys if your file contain similar keys but with different casing. For example, if your file contains:
"abcNews.something" = "foo";
"ABCNews.somethingElse" = "bar";
SwiftGenKit will no longer consolidate these into one "abcNews" case. It is up to the user to fix this inconsistent casing in their strings
files, or to adapt a custom template to take that into consideration.
Groups now have an extra attribute isNamespaced
that reflects the "provides namespace" setting in Xcode.
Migration Guide
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 Contexts 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.
Migration Guide
The following Stencil context variables have been renamed or replaced in SwiftGen 4.2. They will no longer be available after the next major release of SwiftGen 5.0.
If you wrote custom templates for SwiftGen, we advise you to migrate your template to use to these new context variables instead of the old one so that they'll continue to work in 4.2 but also in the upcoming 5.0.
enumName
: has been replaced byparam.enumName
, should provide default value.rgb
andrgba
(for each color): can be composed from the other components.
enumName
: has been replaced byparam.enumName
, should provide default value.fontName
(for each font): has been replaced by thename
property.
enumName
: has been replaced byparam.enumName
, should provide default value.images
: just old,catalogs
contains the structured information.
extraImports
: replaced bymodules
(SwiftGen#243)sceneEnumName
: has been replaced byparam. sceneEnumName
, should provide default value.segueEnumName
: has been replaced byparam. segueEnumName
, should provide default value.template using Stencil.- For each
scene
:isBaseViewController
: removed. You can replace it with a test forbaseType == "ViewController"
.
enumName
: has been replaced byparam.enumName
, should provide default value.strings
andstructuredStrings
: replaced bytables
array, where each table has a structuredlevels
property.tableName
: replaced bytables
array, where each table has aname
property.- for each
level
:subenums
: renamed tochildren
.
- for each
string
:keytail
: renamed toname
.params
structure with thenames
,typednames
,types
,count
anddeclarations
arrays: removed.- These have been replaced by
types
which is an array of types. The previous variables can now be reconstructed using template tags now that Stencil has become more powerful.