SwiftGen 项目教程

SwiftGen 项目教程

swift-gen🎱 Composable, transformable, controllable randomness.项目地址:https://gitcode.com/gh_mirrors/sw/swift-gen

1. 项目的目录结构及介绍

SwiftGen 项目的目录结构如下:

swift-gen/
├── Sources/
│   ├── SwiftGen/
│   │   ├── Commands/
│   │   ├── Config/
│   │   ├── Parsers/
│   │   ├── Templates/
│   │   ├── Utils/
│   │   └── main.swift
│   ├── SwiftGenKit/
│   │   ├── Parsers/
│   │   ├── Templates/
│   │   └── Utils/
│   └── StencilSwiftKit/
│       ├── Extensions/
│       ├── Filters/
│       └── Nodes/
├── Tests/
│   ├── SwiftGenTests/
│   ├── SwiftGenKitTests/
│   └── StencilSwiftKitTests/
├── Package.swift
├── README.md
├── LICENSE
└── Rakefile

目录介绍

  • Sources/: 包含项目的所有源代码。
    • SwiftGen/: 包含 SwiftGen 的主要代码。
      • Commands/: 包含各种命令的实现。
      • Config/: 包含配置文件相关的代码。
      • Parsers/: 包含各种资源解析器的实现。
      • Templates/: 包含生成代码的模板。
      • Utils/: 包含各种工具类和辅助函数。
      • main.swift: 项目的启动文件。
    • SwiftGenKit/: 包含 SwiftGen 的核心功能代码。
      • Parsers/: 包含核心解析器的实现。
      • Templates/: 包含核心模板的实现。
      • Utils/: 包含核心工具类和辅助函数。
    • StencilSwiftKit/: 包含 Stencil 模板引擎的扩展。
      • Extensions/: 包含 Stencil 的扩展。
      • Filters/: 包含 Stencil 的过滤器。
      • Nodes/: 包含 Stencil 的节点。
  • Tests/: 包含项目的所有测试代码。
    • SwiftGenTests/: 包含 SwiftGen 的测试代码。
    • SwiftGenKitTests/: 包含 SwiftGenKit 的测试代码。
    • StencilSwiftKitTests/: 包含 StencilSwiftKit 的测试代码。
  • Package.swift: Swift 包管理文件。
  • README.md: 项目说明文档。
  • LICENSE: 项目许可证。
  • Rakefile: 项目构建脚本。

2. 项目的启动文件介绍

项目的启动文件是 Sources/SwiftGen/main.swift。这个文件是 SwiftGen 的入口点,负责解析命令行参数并调用相应的命令。

main.swift 主要功能

  • 解析命令行参数。
  • 根据参数调用相应的命令。
  • 初始化配置文件。
  • 调用解析器和模板生成器。

3. 项目的配置文件介绍

SwiftGen 使用 YAML 格式的配置文件来定义各种解析器和它们的参数。配置文件的默认名称是 swiftgen.yml

配置文件示例

input_dir: Resources
output_dir: Generated

strings:
  paths: strings.xml
  template: swift4
  output: Strings.swift

fonts:
  paths: Fonts
  template: swift4
  output: Fonts.swift

xcassets:
  paths: Assets.xcassets
  template: swift4
  output: Assets.swift

plists:
  paths: Info.plist
  template: swift4
  output: Plist.swift

配置文件主要内容

  • input_dir: 输入文件的目录。
  • output_dir: 输出文件的目录。
  • strings: 本地化字符串的配置。
    • paths: 输入文件路径。
    • template: 使用的模板。
    • output: 输出文件路径。
  • fonts: 字体的配置。
    • paths: 输入文件路径。
    • template: 使用的模板。
    • output: 输出文件路径。
  • xcassets: 资源目录的配置。
    • paths: 输入文件路径。
    • template: 使用的模板。
    • output: 输出文件路径。
  • plists: Plist 文件的配置

swift-gen🎱 Composable, transformable, controllable randomness.项目地址:https://gitcode.com/gh_mirrors/sw/swift-gen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苏承根

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值