[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6750":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},6750,"Sourcery","krzysztofzablocki\u002FSourcery","krzysztofzablocki","Meta-programming for Swift, stop writing boilerplate code.","http:\u002F\u002Fmerowing.info",null,"Swift",8010,634,81,88,0,1,6,21,4,39.41,"MIT License",false,"master",true,[27,28,29,30,31,32,33],"code-generation","codegen","codegenerator","ios","metaprogramming","swift","templates","2026-06-12 02:01:29","[![macOS 13](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Factions\u002Fworkflows\u002Ftest_macOS.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Factions\u002Fworkflows\u002Ftest_macOS.yml)\n[![ubuntu x86_64](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Factions\u002Fworkflows\u002Ftest_ubuntu.yml\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Factions\u002Fworkflows\u002Ftest_ubuntu.yml)\n\u003C!-- [![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fkrzysztofzablocki\u002FSourcery\u002Fbranch\u002Fmaster\u002Fgraph\u002Fbadge.svg)](https:\u002F\u002Fcodecov.io\u002Fgh\u002Fkrzysztofzablocki\u002FSourcery) -->\n[![docs](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fbadge.svg)](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Findex.html)\n[![Version](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FSourcery.svg?style=flat)](http:\u002F\u002Fcocoapods.org\u002Fpods\u002FSourcery)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fl\u002FSourcery.svg?style=flat)](http:\u002F\u002Fcocoapods.org\u002Fpods\u002FSourcery)\n[![Platform](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fp\u002FSourcery.svg?style=flat)](http:\u002F\u002Fcocoapods.org\u002Fpods\u002FSourcery)\n\n[**In-Depth Sourcery guide is covered as part of my SwiftyStack engineering course.**](https:\u002F\u002Fwww.swiftystack.com\u002F)\n\n**Sourcery Pro provides a powerful Stencil editor and extends Xcode with the ability to handle live AST templates: [available on Mac App Store](https:\u002F\u002Fapps.apple.com\u002Fus\u002Fapp\u002Fsourcery-pro\u002Fid1561780836?mt=12)**\n\nhttps:\u002F\u002Fuser-images.githubusercontent.com\u002F1468993\u002F114271090-f6c19200-9a0f-11eb-9bd8-d7bb15129eb2.mp4\n\n[Learn more about Sourcery Pro](http:\u002F\u002Fmerowing.info\u002Fsourcery-pro\u002F)\n\n\u003Cimg src=\"Resources\u002Ficon-128.png\">\n\n**Sourcery** is a code generator for Swift language, built on top of Apple's own SwiftSyntax. It extends the language abstractions to allow you to generate boilerplate code automatically.\n\nIt's used in over 40,000 projects on both iOS and macOS and it powers some of the most popular and critically-acclaimed apps you have used (including Airbnb, Bumble, New York Times). Its massive community adoption was one of the factors that pushed Apple to implement derived Equality and automatic Codable conformance. Sourcery is maintained by a growing community of [contributors](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Fgraphs\u002Fcontributors).\n\nTry **Sourcery** for your next project or add it to an existing one -- you'll save a lot of time and be happy you did!\n\n## TL;DR\nSourcery allows you to get rid of repetitive code and create better architecture and developer workflows. \nAn example might be implementing `Mocks` for all your protocols, without Sourcery you will need to write **hundreds lines of code per each protocol** like this:\n\n```swift\nclass MyProtocolMock: MyProtocol {\n\n    \u002F\u002FMARK: - sayHelloWith\n    var sayHelloWithNameCallsCount = 0\n    var sayHelloWithNameCalled: Bool {\n        return sayHelloWithNameCallsCount > 0\n    }\n    var sayHelloWithNameReceivedName: String?\n    var sayHelloWithNameReceivedInvocations: [String] = []\n    var sayHelloWithNameClosure: ((String) -> Void)?\n\n    func sayHelloWith(name: String) {\n        sayHelloWithNameCallsCount += 1\n        sayHelloWithNameReceivedName = name\n        sayHelloWithNameReceivedInvocations.append(name)\n        sayHelloWithNameClosure?(name)\n    }\n\n}\n```\n\nand with Sourcery ?\n\n```swift\nextension MyProtocol: AutoMockable {}\n```\n\nSourcery removes the need to write any of the mocks code, how many protocols do you have in your project? Imagine how much time you'll save, using Sourcery will also make every single mock consistent and if you refactor or add properties, the mock code will be automatically updated for you, eliminating possible human errors. \n\nSourcery can be applied to arbitrary problems across your codebase, if you can describe an algorithm to another human, you can automate it using Sourcery.\n\nMost common uses are:\n\n- [Equality](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fequatable.html) & [Hashing](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fhashable.html)\n- [Enum cases & Counts](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fenum-cases.html)\n- [Lenses](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Flenses.html)\n- [Mocks & Stubs](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fmocks.html)\n- [LinuxMain](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Flinuxmain.html)\n- [Decorators](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fdecorator.html)\n- [Persistence and advanced Codable](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fcodable.html)\n- [Property level diffing](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fdiffable.html)\n\nBut how about more specific use-cases, like automatically generating all the UI for your app `BetaSetting`? [you can use Sourcery for that too](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FAutomaticSettings)\n\nOnce you start writing your own template and learn the power of Sourcery you won't be able to live without it.\n\n## How To Get Started\nThere are plenty of tutorials for different uses of Sourcery, and you can always ask for help in our [Swift Forum Category](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Fsourcery).\n\n- [The Magic of Sourcery](https:\u002F\u002Fwww.caseyliss.com\u002F2017\u002F3\u002F31\u002Fthe-magic-of-sourcery) is a great starting tutorial\n- [Generating Swift Code for iOS](https:\u002F\u002Fwww.raywenderlich.com\u002F158803\u002Fsourcery-tutorial-generating-swift-code-ios) deals with JSON handling code\n- [How To Automate Swift Boilerplate with Sourcery](https:\u002F\u002Fatomicrobot.io\u002Fblog\u002Fsourcery\u002F) generates conversions to dictionaries\n- [Codable Enums](https:\u002F\u002Flittlebitesofcocoa.com\u002F318-codable-enums) implements Codable support for Enumerations\n- [Sourcery Workshops](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourceryWorkshops)\n\n### Quick Mocking Intro & Getting Started Video\n\nYou can also watch this quick getting started and intro to mocking video by Inside iOS Dev: \n\u003Cbr \u002F>\n\n[![Watch the video](Resources\u002FInside-iOS-Dev-Sourcery-Intro-To-Mocking-Video-Thumbnail.png)](https:\u002F\u002Fyoutu.be\u002F-ZbBNuttlt4?t=214)\n\n## Installation\n\n- _Binary form_\n\n    Download the latest release with the prebuilt binary from [release tab](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Freleases\u002Flatest). Unzip the archive into the desired destination and run `bin\u002Fsourcery`\n    \n- _[Homebrew](https:\u002F\u002Fbrew.sh)_\n\n\t`brew install sourcery`\n\n- _[CocoaPods](https:\u002F\u002Fcocoapods.org)_\n\n    Add `pod 'Sourcery'` to your `Podfile` and run `pod update Sourcery`. This will download the latest release binary and will put it in your project's CocoaPods path so you will run it with `$PODS_ROOT\u002FSourcery\u002Fbin\u002Fsourcery`\n\n    If you only want to install the `sourcery` binary, you may want to use the `CLI-Only` subspec: `pod 'Sourcery', :subspecs => ['CLI-Only']`.\n\n- _[Mint](https:\u002F\u002Fgithub.com\u002Fyonaskolb\u002FMint)_\n\n    `mint run krzysztofzablocki\u002FSourcery`\n\n- _Building from Source_\n\n    Download the latest release source code from [the release tab](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Freleases\u002Flatest) or clone the repository and build Sourcery manually.\n\n    - _Building with Swift Package Manager_\n\n        Run `swift build -c release` in the root folder and then copy `.build\u002Frelease\u002Fsourcery` to your desired destination.\n\n        > Note: JS templates are not supported when building with SPM yet.\n\n    - _Building with Xcode_\n\n        Run `xcodebuild -scheme sourcery -destination generic\u002Fplatform=macOS -archivePath sourcery.xcarchive archive` and export the binary from the archive.\n\n- _SPM (for plugin use only)_\nAdd the package dependency to your `Package.swift` manifest from version `1.8.3`.\n\n```\n.package(url: \"https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery.git\", from: \"1.8.3\")\n```\n\n- _[pre-commit](https:\u002F\u002Fpre-commit.com\u002F)_\nAdd the dependency to `.pre-commit-config.yaml`.\n\n```\n- repo: https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\n  rev: 1.9.1\n  hooks:\n  - id: sourcery\n```\n\n## Documentation\n\nFull documentation for the latest release is available [here](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002F).\n\n## Linux Support\n\nLinux support is [described on this page](LINUX.md).\n\n## Usage\n\n### Running the executable\n\nSourcery is a command line tool; you can either run it manually or in a custom build phase using the following command:\n\n```\n$ .\u002Fbin\u002Fsourcery --sources \u003Csources path> --templates \u003Ctemplates path> --output \u003Coutput path>\n```\n\n> Note: this command differs depending on how you installed Sourcery (see [Installation](#installation))\n\n### Swift Package command\n\nSourcery can now be used as a Swift package command plugin. In order to do this, the package must be added as a dependency to your Swift package or Xcode project (see [Installation](#installation) above).\n\nTo provide a configuration for the plugin to use, place a `.sourcery.yml` file at the root of the target's directory (in the sources folder rather than the root of the package).\n\n#### Running from the command line\n\nTo verify the plugin can be found by SwiftPM, use:\n\n```\n$ swift package plugin --list\n```\n\nTo run the code generator, you need to allow changes to the project with the `--allow-writing-to-package-directory` flag:\n\n```\n$ swift package --allow-writing-to-package-directory sourcery-command\n```\n\n#### Running in Xcode\n\nInside a project\u002Fpackage that uses this command plugin, right-click the project and select \"SourceryCommand\" from the \"SourceryPlugins\" menu group.\n\n> ⚠️ Note that this is only available from Xcode 14 onwards.\n\n### Command line options\n\n- `--sources` - Path to a source swift files or directories. You can provide multiple paths using multiple `--sources` option.\n- `--templates` - Path to templates. File or Directory. You can provide multiple paths using multiple `--templates` options.\n- `--force-parse` - File extensions of Sourcery generated file you want to parse. You can provide multiple extension using multiple `--force-parse` options. (i.e. `file.toparse.swift` will be parsed even if generated by Sourcery if `--force-parse toparse`). Useful when trying to implement a multiple phases generation. `--force-parse` can also be used to process within a sourcery annotation. For example to process code within `sourcery:inline:auto:Type.AutoCodable` annotation you can use `--force-parse AutoCodable`\n- `--output` [default: current path] - Path to output. File or Directory.\n- `--config` [default: current path] - Path to config file. File or Directory. See [Configuration file](#configuration-file).\n- `--args` - Additional arguments to pass to templates. Each argument can have an explicit value or will have implicit `true` value. Arguments should be separated with `,` without spaces (i.e. `--args arg1=value,arg2`). Arguments are accessible in templates via `argument.name`\n- `--watch` [default: false] - Watch both code and template folders for changes and regenerate automatically.\n- `--verbose` [default: false] - Turn on verbose logging\n- `--quiet` [default: false] - Turn off any logging, only emit errors\n- `--disableCache` [default: false] - Turn off caching of parsed data\n- `--prune` [default: false] - Prune empty generated files\n- `--version` - Display the current version of Sourcery\n- `--help` - Display help information\n- `--cacheBasePath` - Base path to the cache directory. Can be overriden by the config file.\n- `--buildPath` - Path to directory used when building from .swifttemplate files. This defaults to system temp directory\n- `--hideVersionHeader` [default: false] - Stop adding the Sourcery version to the generated files headers.\n- `--headerPrefix` - Additional prefix for headers.\n\n### Configuration file\n\nInstead of CLI arguments, you can use a `.sourcery.yml` configuration file:\n\n```yaml\nsources:\n  - \u003Csources path>\n  - \u003Csources path>\ntemplates:\n  - \u003Ctemplates path>\n  - \u003Ctemplates path>\nforceParse:\n  - \u003Cstring value>\n  - \u003Cstring value>\noutput:\n  \u003Coutput path>\nargs:\n  \u003Cname>: \u003Cvalue>\n```\n\nRead more about this configuration file [here](https:\u002F\u002Fkrzysztofzablocki.github.io\u002FSourcery\u002Fusage.html#configuration-file).\n\n## Issues\nIf you get an unverified developer warning when using binary zip distribution try:\n`xattr -dr com.apple.quarantine Sourcery-1.1.1`\n\n## Contributing\n\nContributions to Sourcery are welcomed and encouraged!\n\nIt is easy to get involved. Please see the [Contributing guide](CONTRIBUTING.md) for more details.\n\n[A list of contributors is available through GitHub](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Fgraphs\u002Fcontributors).\n\nTo clarify what is expected of our community, Sourcery has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and articulates my values well. For more, see the [Code of Conduct](CODE_OF_CONDUCT.md).\n\n## Sponsoring\n\nIf you'd like to support Sourcery development you can do so through [GitHub Sponsors](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fkrzysztofzablocki) or [Open Collective](https:\u002F\u002Fopencollective.com\u002Fsourcery), it's highly appreciated 🙇‍\n\nIf you are a company and would like to sponsor the project directly and get it's logo here, you can [contact me directly](mailto:krzysztof.zablocki@pixle.pl?subject=[Sourcery-Sponsorship])\n\n### Sponsors \n\n[\u003Cimg alt=\"Bumble Inc\" width=\"256px\" src=\"https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Fassets\u002F1468993\u002F159e0943-c890-42b7-9de7-9de9e70dd720\" \u002F>](https:\u002F\u002Fteam.bumble.com\u002Fteams\u002Fengineering)\n\n[\u003Cimg alt=\"Airbnb Engineering\" width=\"128px\" src=\"https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FSourcery\u002Fassets\u002F1468993\u002Fb1c06e1c-06da-4a77-a4f1-7dabd02bbaba\" \u002F>](https:\u002F\u002Fairbnb.io\u002F)\n\n## License\n\nSourcery is available under the MIT license. See [LICENSE](LICENSE) for more information.\n\n## Attributions\n\nThis tool is powered by\n\n- [Stencil](https:\u002F\u002Fgithub.com\u002Fkylef\u002FStencil) and few other libs by [Kyle Fuller](https:\u002F\u002Fgithub.com\u002Fkylef)\n\nThank you! to:\n\n- [Mariusz Ostrowski](http:\u002F\u002Ftwitter.com\u002Ffaktory) for creating the logo.\n- [Artsy Eidolon](https:\u002F\u002Fgithub.com\u002Fartsy\u002Feidolon) team, because we use their codebase as a stub data for performance testing the parser.\n- [Olivier Halligon](https:\u002F\u002Fgithub.com\u002FAliSoftware) for showing me his setup scripts for CLI tools which are powering our rakefile.\n- [JP Simard](https:\u002F\u002Fgithub.com\u002Fjpsim) for creating [SourceKitten](https:\u002F\u002Fgithub.com\u002Fjpsim\u002FSourceKitten) that originally powered Sourcery and was instrumental in making this project happen. \n\n## Other Libraries \u002F Tools\n\nIf you want to generate code for asset related data like .xib, .storyboards etc. use [SwiftGen](https:\u002F\u002Fgithub.com\u002FAliSoftware\u002FSwiftGen). SwiftGen and Sourcery are complementary tools.\n\nMake sure to check my other libraries and tools, especially:\n- [KZPlayground](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FKZPlayground) - Powerful playgrounds for Swift and Objective-C\n- [KZFileWatchers](https:\u002F\u002Fgithub.com\u002Fkrzysztofzablocki\u002FKZFileWatchers) - Daemon for observing local and remote file changes, used for building other developer tools (Sourcery uses it)\n\nYou can [follow me on Twitter][1] for news\u002Fupdates about other projects I am creating.\n\n [1]: http:\u002F\u002Ftwitter.com\u002Fmerowing_\n","Sourcery 是一个针对 Swift 语言的代码生成工具，旨在帮助开发者减少样板代码的编写。它基于 Apple 的 SwiftSyntax 构建，允许用户通过定义模板来自动生成代码，从而提高开发效率和代码质量。该项目支持 iOS 和 macOS 平台，并且在超过 40,000 个项目中得到应用，包括一些知名应用如 Airbnb、Bumble 和纽约时报等。Sourcery 的核心功能包括自动生成协议实现、模型类的 Codable 符合性以及 Mock 对象等，非常适合需要频繁处理重复编码任务的应用场景。使用 Sourcery 可以显著提升开发速度并优化项目架构。",2,"2026-06-11 03:08:42","top_language"]