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 automates the creation of type-safe constants for iOS and macOS project resources. It reads asset catalogs, localized strings, storyboards, fonts, and other files to generate Swift code that replaces error-prone string literals with compile-time checked enums and functions. This eliminates runtime crashes from typos and missing resources while providing full autocompletion.
iOS and macOS developers working on Swift projects who want to improve code safety and maintainability when accessing resources like images, strings, and storyboard elements.
Developers choose SwiftGen because it provides a robust, customizable solution for type-safe resource access that integrates seamlessly into Xcode workflows. Unlike manual constants or string-based APIs, it guarantees compile-time validation, reduces boilerplate, and supports advanced features like pluralization and structured localization through templates.
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.
Eliminates runtime crashes from typos by replacing string literals with type-safe constants, as highlighted in the README's philosophy of preventing errors.
Supports assets, strings, fonts, storyboards, JSON, YAML, and more, covering most iOS/macOS resource types with dedicated parsers.
Uses Stencil templates to tailor generated code to specific Swift versions and project conventions, allowing flexibility beyond bundled options.
Offers multiple installation methods like CocoaPods and configuration files, ensuring consistent setup across teams, as detailed in the Installation section.
Requires setting up and maintaining a YAML config file and understanding parsers/templates, which can be steep for new users.
Resource changes necessitate re-running SwiftGen, lacking support for dynamic updates without recompilation, which may hinder rapid iteration.
Can generate large Swift files for projects with many resources, increasing compilation times and app size if not managed carefully.