美文网首页
使用Swiftgen自动生成 assets

使用Swiftgen自动生成 assets

作者: 雾霾下的天空 | 来源:发表于2019-12-04 15:34 被阅读0次

swiftgem 安装地址
brew 安装地址

我是通过 brew 进行安装

$  brew update
$  brew install swiftgen

使用方法
一种是直接使用命令

swiftgen xcassets --templateName swift4 --output UIImage+Assets.swift Assets.xcassets

一种是编写 yml 脚本
新建文件 swiftgem.yml 默认文件名

xcassets:
    inputs:
        Media.xcassets
    outputs:
        templateName: swift4
        output: UIImage+Assets.swift

可以运行 swiftgen config lint 进行校验

Linting swiftgen.yml
> Common parent directory used for all input paths:  <none>
> Common parent directory used for all output paths: <none>
> 1 entry for command xcassets:
 $ swiftgen xcassets --templateName swift4 --output UIImage+Assets.swift Media.xcassets

执行脚本
swiftgen config

默认在当前路径生成文件 拖入工程中

相关文章

网友评论

      本文标题:使用Swiftgen自动生成 assets

      本文链接:https://www.haomeiwen.com/subject/ddrlgctx.html