# krzysztofzablocki/sourcery

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/krzysztofzablocki-sourcery).**

8,012 stars · 634 forks · Swift · MIT

## Links

- GitHub: https://github.com/krzysztofzablocki/Sourcery
- Homepage: http://merowing.info
- awesome-repositories: https://awesome-repositories.com/repository/krzysztofzablocki-sourcery.md

## Description

Sourcery is a code generation tool for Swift that automates the production of repetitive boilerplate and protocol conformance. It functions as a template engine that scans source files to generate structural code, such as Codable, Equatable, and Hashable implementations, based on marker protocols and static analysis.

The project provides a specialized mocking framework that creates mock objects for protocols to track function calls and capture arguments during testing. It also includes utilities for generating struct lenses, enum case collections, and precise property-level test diffs.

The system supports a real-time workflow using a background daemon for file monitoring and automatic code regeneration. Integration is managed through YAML-driven configuration files and build system plugins to ensure generated code remains consistent during refactoring.

## Tags

### Development Tools & Productivity

- [Swift Code Generators](https://awesome-repositories.com/f/development-tools-productivity/swift-code-generators.md) — Provides a comprehensive tool for automating the creation of boilerplate and protocol conformance code for Swift projects.
- [Template-Based Code Generators](https://awesome-repositories.com/f/development-tools-productivity/template-based-code-generators.md) — Functions as a template engine that automates the creation of repetitive structural Swift code.
- [Boilerplate Generators](https://awesome-repositories.com/f/development-tools-productivity/code-generators/boilerplate-generators.md) — Automates the production of repetitive structural code to eliminate manual errors. ([source](https://github.com/krzysztofzablocki/sourcery#readme))
- [Marker Protocol Detection](https://awesome-repositories.com/f/development-tools-productivity/structural-marker-detection/marker-protocol-detection.md) — Implements code generation triggers by scanning for specialized marker protocols on Swift types.
- [Build System Integrations](https://awesome-repositories.com/f/development-tools-productivity/build-system-integrations.md) — Runs custom code generation scripts as plugins during the compilation process.
- [Build Plugin Integrations](https://awesome-repositories.com/f/development-tools-productivity/build-tooling/build-orchestration-logic/build-orchestration-configuration/build-automation-systems/build-systems/build-plugin-integrations.md) — Integrates the generation process into the build system via plugins to ensure output is up to date. ([source](https://github.com/krzysztofzablocki/sourcery#readme))
- [Automatic Code Regeneration](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-analysis-and-transformation/automated-code-refactoring/automatic-code-regeneration.md) — Automatically regenerates dependent code in real-time to maintain consistency during refactoring. ([source](https://github.com/krzysztofzablocki/sourcery#readme))
- [Real-time Generation Previews](https://awesome-repositories.com/f/development-tools-productivity/real-time-generation-previews.md) — Provides immediate feedback by updating generated code in real-time as templates are modified. ([source](https://krzysztofzablocki.github.io/Sourcery/index.html))
- [Swift Refactoring Tools](https://awesome-repositories.com/f/development-tools-productivity/swift-refactoring-tools.md) — Maintains project consistency by automatically regenerating dependent code when source properties change.

### Programming Languages & Runtimes

- [Hashable Object Generators](https://awesome-repositories.com/f/programming-languages-runtimes/hashable-object-generators.md) — Automates the creation of hashing logic for types to remove manual boilerplate. ([source](https://krzysztofzablocki.github.io/Sourcery/hashable.html))
- [Codable Implementation Generation](https://awesome-repositories.com/f/programming-languages-runtimes/protocol-conformance-implementations/codable-implementation-generation.md) — Automatically generates Codable conformance by analyzing associated values and marker protocols. ([source](https://krzysztofzablocki.github.io/Sourcery/codable.html))
- [Equatable Conformance Generation](https://awesome-repositories.com/f/programming-languages-runtimes/protocol-conformance-implementations/equatable-conformance-generation.md) — Eliminates manual boilerplate by automatically creating equality comparison logic. ([source](https://krzysztofzablocki.github.io/Sourcery/equatable.html))
- [Protocol Conformance Automation](https://awesome-repositories.com/f/programming-languages-runtimes/protocol-conformance-implementations/protocol-conformance-automation.md) — Automatically creates implementations for standard Swift protocols to eliminate tedious manual work.
- [Real-time Regeneration Engines](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/source-code-templates/real-time-regeneration-engines.md) — Regenerates Swift source code in real-time by monitoring changes to templates and source files via a background daemon.

### Testing & Quality Assurance

- [Mocking Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/mocking-frameworks.md) — Implements a framework that generates mock objects for protocols to track function calls and capture arguments.
- [Protocol-to-Mock Generators](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/interface-to-mock-generators/protocol-to-mock-generators.md) — Creates mock classes for protocols to track function calls and capture arguments during testing. ([source](https://krzysztofzablocki.github.io/Sourcery/mocks.html))
- [Static Analysis AST Parsing](https://awesome-repositories.com/f/testing-quality-assurance/static-code-analysis/ast-extraction/static-analysis-ast-parsing.md) — Parses source code into structural metadata to populate code generation templates.

### Operating Systems & Systems Programming

- [Directory Monitoring Daemons](https://awesome-repositories.com/f/operating-systems-systems-programming/system-administration-maintenance/system-services/background-daemons/directory-monitoring-daemons.md) — Provides a background daemon that monitors source files to trigger immediate code regeneration.

### Software Engineering & Architecture

- [YAML Configuration Files](https://awesome-repositories.com/f/software-engineering-architecture/application-lifecycle-management/configuration-management/configuration-formats-and-schemas/yaml-configuration-files.md) — Uses YAML configuration files to define source paths and template arguments for the generation process.
- [Generation Configuration Schemas](https://awesome-repositories.com/f/software-engineering-architecture/application-lifecycle-management/configuration-management/configuration-formats-and-schemas/yaml-configuration-files/generation-configuration-schemas.md) — Uses YAML files to define source paths and template mappings for automated code production.

### Part of an Awesome List

- [Development Tools](https://awesome-repositories.com/f/awesome-lists/devtools/development-tools.md) — Automates boilerplate code generation via meta-programming.
