Sourcery Pro is a Mac App that extends Xcode with the ability to create your own live templates that understand your code structure.
Do you hate writing same repetitive Swift patterns over and over again?
Now you don’t need to, it’s just a shortcut away.
Popular use-cases:
- Create mock implementation from a selected protocol
- Add Codable support to enums with associated values
- Kickstart your Composable Architecture boilerplate
- Generate property level tests
- Generate test specs from your classes
- Generate SwiftUI view from a struct
- Create Prisms and Lenses for your data
It comes bundled with 14 starting templates and features a powerful Template editor with code completion, inline documentation, and a built-in error checker/linter that makes writing your custom automation a breeze.
Built on top of my Sourcery tool that is used in over 40 000 Swift apps, including products like Airbnb, Bumble, and The New York Times.
It saved those apps millions of dollars in development time, and now you can save both your time and regain some of the sanity by stopping to write the same code over and over again, how much is your time worth?
This app is the culmination of 5 years of work and thousands of development hours, it’s simply the most powerful Xcode extension ever created.
Even if you never heard of Sourcery, you’ll have no problem creating your own templates, and if you are a Sourcery user this tool not only makes creating your templates a completely different experience but also adds additional use-cases that are simply not possible with full CLI automation that I normally recommend with it.
You can share your templates with your friends and team by drag & dropping or right-clicking on the template in the list.
More info
Xcode integration
The app provides an Xcode Source extensions that let’s you run templates you have against the code of your projects, see it in action:
Editor
Sourcery Pro standalone app features an editor:
- Comes bundled with over 10 templates to get you started
- Even though Stencil doesn’t haves types, Sourcery Pro gives you ability to add type attribution to your templates
- Powerful code completion and inline documentation to make writing your own templates simpler.
- Inline errors and warnings
- Over 20 different color themes to choose from
- Drag & Drop and import / export your templates to share with community or team members (Cloud sharing coming soon)
- Bind key shortcuts to Sourcery Pro templates right in Xcode
Writing templates
Sourcery Pro adds additional functionality on top of regular stencil:
{% typed variable as MyType %}
lets you add type information to macros, simply declare it after defining your macro and Sourcery Pro will start providing you with all type information for yourvariable
{% newline %}
ends whitespace trimming in the template and adds an extra empty line
FAQ
- Sourcery Pro extension doesn’t appear in my editor, what to do?
- This can happen if you have multiple Xcode instances or other non-standard setup, follow this guide on how to fix it
- My templates don’t appear in Xcode?
- When you add/remove templates you need to restart Xcode, it’s the limitation of Xcode Source Extension. Also make sure that you marked Templates as available in Xcode (default), you can right click on template in the list to see other options
- How do I share templates?
- Right click on the template list to see context menu
- Or just drag & drop from / to it
- Where can I report feedback or ask questions?