SwiftGen

Welcome to the docset landing page for SwiftGen! SwiftGen is an open-source command-line tool designed to auto-generate Swift code for resources of your projects, making them type-safe to use.

About SwiftGen

SwiftGen is a powerful tool that can streamline and automate the way you handle resources in your Swift projects. By parsing your project’s assets and generating code for them, SwiftGen simplifies the development process and ensures safety by providing compile-time checks of these resources. SwiftGen supports several types of resources, such as images, localized strings, fonts, and more.

Features of SwiftGen

  • Type-Safe: No more string-based API to access your resources.
  • Compile-Time Check: Resource usage is checked at compile time.
  • Customizable Templates: SwiftGen uses Stencil templates that you can customize to your needs.
  • One Tool for All Resources: SwiftGen supports several types of resources.

How to Install SwiftGen

There are a few different options for installing SwiftGen:

  • Homebrew: Use the command `brew install swiftgen`.
  • Mint: Use the command `mint install SwiftGen/SwiftGen`.
  • CocoaPods: Use the command `pod ‘SwiftGen’, ‘~> VERSION’`.

Usage of SwiftGen

To use Swiftgen, you need to create a configuration file named `swiftgen.yml` in your project’s root directory. This file will allow SwiftGen to know what kind of code to generate, from which resources.

An example of a simple configuration file could look like this:

strings:
  inputs: path/to/Localizable.strings
  outputs:
    - templateName: swift5
      output: path/to/Generated/Strings+Generated.swift

Contributing to SwiftGen

SwiftGen is an open-source project and welcomes contributions and improvements from the community! If you have suggestions or want to get involved, you can start by checking our GitHub repository and our contributing guidelines.

Contact Information

If you have questions or need further assistance, feel free to engage with us on GitHub or join our community on Gitter.