A Swift code generator for type-safe access to assets, strings, fonts, and other resources in iOS/macOS projects.
SwiftGen is a Swift code generator that creates type-safe constants for project resources like images, localized strings, fonts, and storyboards. It solves the problem of error-prone string-based APIs by generating compile-time validated code, reducing runtime crashes and improving developer productivity through autocompletion.
iOS and macOS developers working on Swift projects who want to eliminate string-based resource access and ensure type safety for assets, localization, and other project resources.
Developers choose SwiftGen because it provides a robust, customizable solution for type-safe resource management, with support for multiple resource types, flexible templates, and seamless integration into existing Xcode workflows.
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates Swift enums and structs for assets, strings, and fonts, replacing error-prone string literals with autocompleted constants, as shown in the asset catalog and strings parser examples.
Prevents runtime crashes from typos or missing resources by leveraging Swift's type system, ensuring all resource usage is checked at compile time.
Uses Stencil templates to tailor generated code to specific Swift versions and project conventions, with bundled templates for Swift 4 and 5, and support for custom templates.
Handles a wide range of resource types including Asset Catalogs, strings, fonts, Interface Builder files, Core Data, JSON/YAML, and plists, making it a comprehensive solution.
Requires creating and maintaining a YAML configuration file (swiftgen.yml), which adds setup complexity and can be error-prone compared to simpler tools.
Customizing templates necessitates learning Stencil syntax, and the default templates might not fit all project needs without modification, as admitted in the JSON/YAML parser documentation.
Integrating into Xcode build phases means code generation runs on every build, potentially slowing down development cycles for large projects with many resources.