Generate Swift code programmatically with declarative syntax. SyntaxKit is a Swift package that provides a type-safe, result builder-based API for generating Swift code structures. It's designed for macro development, model transformers, and migration utilities—scenarios where you need to programmatically create Swift code rather than writing it by hand.
Unlike manually writing SwiftSyntax AST nodes, SyntaxKit uses result builders to make code generation readable and maintainable. Perfect for macro authors who need to generate complex Swift structures, or developers building tools that automatically create boilerplate code from external schemas, APIs, or configurations.
- When to Use SyntaxKit
- Installation
- Quick Start
- Why SyntaxKit Excels
- Features
- Documentation
- Contributing
- Requirements
- License
✅ Choose SyntaxKit when:
- Building Swift macros or compiler plugins
- Generating Swift code from external schemas (GraphQL, databases, JSON schemas)
- Creating developer tools that output Swift code
- Building code generators or transformers
- Need type-safe programmatic Swift code construction
❌ Use regular Swift when:
- Writing application business logic
- Creating UI components or view controllers
- Building standard iOS/macOS app features
- Code you'd write once and maintain manually
🎓 New to SyntaxKit? Start with our Complete Getting Started Guide - from zero to building your first macro in 10 minutes.
Add SyntaxKit to your project using Swift Package Manager:
✅ Done! You've built type-safe Swift code generation. Ready for complex scenarios like API client generation or model transformers.
SyntaxKit provides a set of result builders that allow you to create Swift code structures in a declarative way. Here's an example:
This will generate the following Swift code:
- Create structs, enums, and cases using result builders
- Add inheritance and comments to your code structures
- Generate formatted Swift code using SwiftSyntax
- Type-safe code generation
- Comprehensive support for Swift language features
- 🚀 Getting Started Guide - Your first SyntaxKit project in 10 minutes
- 🔧 Macro Development Tutorial - Complete macro creation walkthrough
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - Community questions and showcases
We welcome contributions to SyntaxKit! Whether you're fixing bugs, adding features, or improving documentation, your help makes SyntaxKit better for everyone.
- Documentation Contribution Guide - Standards and review process for documentation changes
- Review checklist for tutorials, articles, and API documentation
- Guidelines for writing clear, tested examples
- Check existing issues and discussions to avoid duplicates
- For documentation changes, follow CONTRIBUTING-DOCS.md guidelines
- Ensure all tests pass and code follows project standards
- Consider adding tests for new functionality
- Swift 6.0+
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 For OpenAPI code generation: Check out the official Swift OpenAPI Generator for generating Swift code from OpenAPI specifications.