krzysztofzablocki/sourcery

Meta-programming for Swift, stop writing boilerplate code.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 21 minutes ago
Added to GitGenius on September 8th, 2026
Created on December 11th, 2016
Open Issues & Pull Requests: 94 (+0)
GitHub issues: Enabled
Number of forks: 633
Total Stargazers: 8,020 (+0)
Total Subscribers: 83 (+0)

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Issue API getrepoissuespagesummary failed: 429 Rate limit exceeded. Please try again later.

Detailed Description

Sourcery is a code generator for Swift that automates the creation of boilerplate code using meta-programming built on Apple's SwiftSyntax.

Sourcery solves the problem of repetitive code generation by allowing developers to define templates that automatically produce consistent implementations across their codebase. Rather than manually writing hundreds of lines of code for each protocol or type, developers describe the pattern once as a template, and Sourcery generates all instances automatically. This approach ensures consistency, eliminates human error, and automatically updates generated code when the source types change. The tool parses Swift code into an abstract syntax tree and applies Stencil-based templates to generate new code.

Sourcery suits projects of any size where boilerplate is prevalent, from small apps to large codebases used by major companies. It excels at generating equality implementations, hashing, mocks and stubs, Codable conformances, lenses, and enum utilities. Developers should adopt it when they find themselves writing the same code patterns repeatedly or when they need to maintain consistency across many similar implementations. The tool is flexible enough to handle arbitrary code generation problems beyond the common use cases, provided the pattern can be algorithmically described. A commercial offering called Sourcery Pro extends the tool with a Stencil editor and live AST template support within Xcode.

The project maintains active community engagement through a Swift Forum category dedicated to Sourcery discussions and provides multiple tutorials for different use cases. Development is sustained by a growing community of contributors rather than a single maintainer. The tool's adoption across tens of thousands of projects demonstrates sustained real-world usage and validation of its approach.