krzysztofzablocki/Sourcery
Swift MITMeta-programming for Swift, stop writing boilerplate code.
8k
Stars
634
Forks
94
Open issues
0
Contributors
AI Analysis
Sourcery is a code generator for Swift that automatically generates boilerplate code using templates and Apple's SwiftSyntax. It eliminates repetitive coding tasks in iOS and Swift projects through meta-programming abstractions. Developers benefit from faster development cycles and reduced manual code maintenance.
Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.
AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.
Sourcery brings Swift meta-programming to 40,000+ projects by generating boilerplate from type annotations
Sourcery is a Swift code generation tool built on Apple's SwiftSyntax that lets developers describe code patterns once via Stencil templates, then auto-generates mocks, Equatable conformances, Codable extensions, and arbitrary boilerplate. It targets iOS/macOS developers working in medium-to-large Swift codebases where repetitive, error-prone hand-written code accumulates. Claimed usage in 40,000+ projects and in apps from Airbnb, Bumble, and New York Times gives it credible production credibility. It has been maintained continuously since 2016 and has directly influenced Swift language evolution.
Created in December 2016 by Krzysztof Zabłocki when Swift lacked generics-derived conformances; originally used SourceKit, later migrated to Apple's SwiftSyntax. Its influence contributed to Swift adopting automatic Codable and Equatable synthesis.
Growth peaked in the 2017–2020 period as Swift adoption surged and teams sought to manage boilerplate in increasingly large codebases. Stars have plateaued near 8,000, likely because Apple's own language improvements absorbed some use cases (Codable, Equatable) and Swift Macros (SE-0382, Swift 5.9+) offer a native alternative. The project remains stable rather than high-growth.
README explicitly names Airbnb, Bumble, and New York Times as users and claims 40,000+ projects. These are plausible given the tool's longevity and the scale of the iOS/macOS ecosystem. The claim is unverifiable from repository metadata alone, but the specificity and the project's age make it credible rather than marketing inflation.
Appears to parse Swift source via SwiftSyntax to construct an AST-based type model, expose that model to Stencil (Jinja2-like) or Swift templates, then write generated files back to disk. Likely runs as a CLI tool integrable into Xcode build phases or CI pipelines. The Sourcery Pro Mac app extends this with a live editor, suggesting the core engine is decoupled from its CLI interface.
CI badges for macOS 13 and Ubuntu x86_64 workflows are visible in the README, indicating automated test runs on both platforms. Specific coverage percentage is not documented in the README; a codecov badge is present but commented out.
Last push was June 11, 2026 — approximately 15 days before the evaluation date — indicating active, recent maintenance. The project has been continuously maintained for nearly a decade. CI is running on both macOS and Linux. 634 forks and an active contributors graph suggest a healthy contributor base, not a single-maintainer bus-factor project.
ADOPT IF: you maintain a mid-to-large Swift codebase on iOS/macOS that predates Swift 5.9 Macros, or you need flexible, multi-pattern code generation that goes beyond what Swift Macros currently offer out of the box — particularly for mock generation. AVOID IF: you are starting a greenfield Swift project targeting iOS 17+/Swift 5.9+ and can invest in authoring Swift Macros natively, or if you want zero external build-phase dependencies. MONITOR IF: you currently rely on Sourcery heavily and are planning a Swift Macros migration — track whether the Swift Macros ecosystem fills your specific template use cases before committing to a switch.
Independent dimensions
Mainstream potential
3/10
Technical importance
8/10
Adoption evidence
8/10
- Swift Macros represent a structural long-term threat: as the macro ecosystem matures and minimum deployment targets rise, the incremental value of Sourcery will narrow for new projects.
- Build-phase integration complexity — Sourcery runs as an external code generation step, which can cause friction with Xcode's build system, SPM pure setups, and incremental compilation.
- Template maintenance burden: teams must own and maintain their Stencil templates over time; when Swift syntax evolves, templates may break and require updates.
- Single primary maintainer historically increases bus-factor risk, even with a contributor community — though the decade-long track record partially mitigates this concern.
- Platform scope is inherently limited to Swift/Apple ecosystem, meaning the project cannot expand its addressable market and long-term star growth is likely to remain flat.
Sourcery will likely remain a stable, well-maintained tool serving its existing user base for several more years, but will see gradual adoption decline among new projects as Swift Macros mature. It may evolve into a bridge/migration tool or focus on advanced patterns macros cannot yet handle.
Explore similar
Newsletter
Get analyses like this every Monday
Free weekly digest of the most interesting open-source discoveries.
Languages
No language breakdown available.
Information
- Website
- http://merowing.info
- Language
- Swift
- License
- MIT
- Last updated
- 4w ago
- Created
- 117mo ago
- Analyzed with
- anthropic/claude-haiku-4-5
Stars over time
No commit data available.
Contributors over time
Top 100 contributors only — repos with more will plateau at 100.
Open issues
No open issues — clean slate.
Open pull requests
No open pull requests.
Top contributors
Contributor data not available yet.
Recent releases
No releases published yet.
Similar repos
| Repository | Stars | Week Δ | Language | Score | Updated |
|---|---|---|---|---|---|
|
|
8k | — | Swift | 8/10 | 4w ago |
|
|
9.6k | — | Swift | 8/10 | 3mo ago |
|
|
8.6k | — | Swift | 8/10 | 3mo ago |
|
|
70.1k | — | Swift | 9/10 | 4h ago |
|
|
8.9k | — | Swift | 8/10 | 17h ago |
The most significant long-term pressure on Sourcery. Swift Macros are built into the compiler, require no external build step, and ship with Xcode. However, they require Swift 5.9+ (iOS 17+ deployment in some configurations), have a steeper authoring curve, and don't yet cover all patterns Sourcery handles. Sourcery remains relevant for teams targeting older OS versions or needing flexible Stencil-based templating.
SwiftGen generates type-safe accessors for assets, strings, storyboards, and colors — a narrower, complementary scope. The two tools are often used together rather than as alternatives. SwiftGen does not offer general-purpose code generation from type metadata.
Mockolo (by Uber) focuses specifically on mock generation for Swift protocols and claims faster performance on large codebases. It competes directly with Sourcery's most popular use case (AutoMockable) but lacks Sourcery's general-purpose templating.
Needle targets dependency injection code generation specifically. Overlaps only with Sourcery's DI-related templates; Sourcery is more general-purpose but requires user-written templates for DI patterns.
Gyb is a lower-level Python-based templating tool used internally by Apple. It lacks Sourcery's Swift-type-awareness, has no community template library, and is not practical for typical app developers.