A Swift code generator that automates boilerplate code using meta-programming and SwiftSyntax.
Sourcery is a code generator for Swift that uses meta-programming to automate boilerplate code. It analyzes Swift source code and generates additional code based on customizable templates, solving the problem of writing repetitive, error-prone code for tasks like mocking, Equatable conformance, and Codable implementations.
Swift developers working on iOS, macOS, or Linux projects who need to reduce boilerplate code, improve code consistency, and automate repetitive coding patterns.
Developers choose Sourcery because it dramatically reduces manual coding effort, ensures consistency across generated code, and integrates seamlessly with Swift projects through multiple installation methods including Swift Package Manager, CocoaPods, and Homebrew.
Meta-programming for Swift, stop writing boilerplate code.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically generates hundreds of lines of mock code per protocol, as shown in the TL;DR example, drastically reducing manual effort for common tasks like AutoMockable.
Ensures generated code like Equatable conformance is uniform and updates automatically with refactors, minimizing human error in boilerplate.
Supports Stencil templates for custom code generation, allowing automation of any describable algorithm beyond built-in use cases such as UI generation.
Used in over 40,000 projects including major apps like Airbnb and The New York Times, indicating robust community adoption and maintenance.
Creating custom templates requires proficiency in Stencil templating language and understanding of SwiftSyntax, which can be challenging for newcomers without prior experience.
Integration as a command-line tool or build phase adds complexity to the development workflow and can slow down build times, especially in large projects.
Only supports Swift, making it unsuitable for projects using multiple programming languages or needing cross-platform code generation tools.
Relies on stable SwiftSyntax, which might break with Swift compiler updates, requiring frequent maintenance and potential downtime for generated code.