Sourcery

screenshot of Sourcery

Meta-programming for Swift, stop writing boilerplate code.

Overview:

Sourcery is a code generator for the Swift language, designed to automate the generation of boilerplate code. It is built on top of Apple's SwiftSyntax and extends the language abstractions to allow for the automatic generation of repetitive code. Sourcery is used in over 40,000 projects on both iOS and macOS, including popular apps like Airbnb, Bumble, and the New York Times. It provides a powerful Stencil editor and extends Xcode with the ability to handle live AST templates. Sourcery saves developers time by removing the need to write repetitive code, creating better architecture and developer workflows.

Features:

  • Automatic Code Generation: Sourcery allows you to automatically generate boilerplate code, such as mocks for protocols, saving you time and eliminating human errors.
  • Massive Community Adoption: Sourcery is widely used in over 40,000 projects on iOS and macOS, with popular apps like Airbnb and the New York Times relying on it for code generation.
  • Extensible Templates: Sourcery provides a powerful Stencil editor that allows you to write your own code generation templates, giving you full control over the code that is generated.
  • Integration with Xcode: Sourcery extends Xcode with the ability to handle live Abstract Syntax Tree (AST) templates, making it easy to generate code within your Xcode project.
  • Support for Complex Use-Cases: Sourcery can be applied to arbitrary problems across your codebase, whether it's generating equality and hashing code, implementing decorators, or automating UI generation.