SwiftGen / SwiftGen

The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The SwiftGen configuration automatically substitutes fileprivate in the initialization of ColorAsset

Az-Su opened this issue · comments

The SwiftGen configuration automatically substitutes fileprivate in the initialization of ColorAsset
The problem is that the SwiftGen configuration file puts the fileprivate access modifier to the init field. I can change it manually to public. However, after the next run of the configuration, it will change init again. How can this problem be solved?
Here is what is written in the configuration file:

xcassets:
  - inputs:
    - Images.xcassets
    outputs:
    - templateName: swift5
      output: AlmazImages.swift
      params:
        enumName: AlmazImages
        publicAccess: true
        forceProvidesNamespaces: true
        bundle: Almaz.resourcesBundle
  - inputs:
    - Colors.xcassets
    outputs:
    - templateName: swift5
      output: AlmazColors.swift
      params:
        enumName: AlmazColors
        publicAccess: true
        forceProvidesNamespaces: true
        bundle: AlmazUI.resourcesBundle

How it should be:

init(name: String) {
    self.name = name
  }

After running the config file:

fileprivate init(name: String) {
    self.name = name
  }

This is the default implementation of the xcassets stencil.

I do not know why you need to change the scope of this function (note that you did not change it to public but to internal in your example) but if you need the generated code to be tailored to your need, I invite you to use a custom template instead of an embedded one.

Duplicate our existing template, update it to your needs and reference it using the templatePath option in your configuration file.

This should solve your issue, if you have any question or problem, feel free to comment or reopen the issue.

Cheers!