LoginSignup
7
1

More than 3 years have passed since last update.

[Deprecated] SwiftGenのConfigFile.md(SwiftGen.ymlの書き方)が、現行バージョンの5.3.0に関する内容ではない

Last updated at Posted at 2018-06-12

SwiftGen 6系がリリースされて、めでたく"paths"keyが"inputs"keyにrenameされていましたので本記事はお役御免となりました。
ちなみに、2019/07/06時点でのSwiftGenの最新版は6.1.0です。

The swiftgen.yml config file now accepts multiple outputs for each command, allowing you to generate multiple outputs from the same files and content. This also means that the output parameter is now deprecated, in favour of the outputs parameter, and it may be removed in a future version of SwiftGen. Similarly, the paths parameter has been renamed to inputs for consistency. You can always use swiftgen config lint to validate your configuration file.

以下は元記事です。


ドキュメントで推奨している通りにswiftgen.ymlの設定をしたのに、エラーになってハマったのでメモしておきます。

環境

ツール バージョン
SwiftGen 5.3.0

ハマった現象

SwiftGenのmasterにあるConfigFile.mdに書かれている推奨設定でswiftgen.ymlを作成すると、以下のエラーが発生します。

Missing entry for key xxxx.paths.
Command /bin/sh failed with exit code 1

原因

SwiftGenのmasterにあるConfigFile.mdが、リリース前の最新バージョンの内容になっていることが原因。
最新バージョンでは現行バージョンの5.3.0には存在しない"inputs"keyが追加&推奨されていたため、5.3.0では必須の"paths"keyが見つからないエラーが発生していました。

Branch/Tag URL
master https://github.com/SwiftGen/SwiftGen/blob/master/Documentation/ConfigFile.md
master-example-swiftgen.yml
input_dir: Sources/Resources
output_dir: Sources/Generated/
strings:
  inputs: Base.lproj/Localizable.strings
  outputs:
    - templateName: structured-swift3
      output: L10n-Constants.swift
xcassets:
  - inputs: Logos.xcassets
    outputs:
      - templateName: swift3
        output: Logos-Constants.swift
        params:
          enumName: Logos
  - inputs:
      - Colors.xcassets
      - Images.xcassets
    outputs:
      - templatePath: customswift3
        output: Assets-Constants.swift

回避方法

現行バージョンのTag 5.3.0に紐づいたConfigFile.mdの内容は正しいので、こちらを参照してSwiftGen.ymlを作成することで問題なく実行できます。

Branch/Tag URL
5.3.0 https://github.com/SwiftGen/SwiftGen/blob/5.3.0/Documentation/ConfigFile.md
5.3.0-example-swiftgen.yml
input_dir: Sources/Resources
output_dir: Sources/Generated/
strings:
  paths: Base.lproj/Localizable.strings
  templateName: structured-swift3
  output: L10n-Constants.swift
xcassets:
  - paths: Logos.xcassets
    templateName: swift3
    output: Logos-Constants.swift
    params:
      enumName: Logos
  - paths:
      - Colors.xcassets
      - Images.xcassets
    templatePath: customswift3
    output: Assets-Constants.swift

備考

本件についてはすでに下記Issueで議論されていたので、近日中にmasterのドキュメントが修正される可能性はありそうです。

7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1