ericodx/swift-marshal
**Ensure consistent member ordering in Swift types to improve readability and maintainability.**
Why
Inconsistent member ordering increases:
- cognitive load when navigating code
- friction during code reviews
- inconsistency across teams and codebases
swift-marshal helps maintain a predictable structure, making code easier to read, review, and maintain.
Features
- Ensures consistent member ordering using AST-based analysis
- Preserves original logic and formatting
- Supports automated fixes via CLI
- Can be integrated into CI pipelines
- Configurable through a declarative YAML file
Install
brew tap ericodx/homebrew-tools
brew install swift-marshalOther installation methods — pre-built binary, build from source, pre-commit hook, Xcode plugin — are covered in the Installation Guide.
Quick start
# Generate a config file (auto-detects your source directories)
swift-marshal init
# Check for violations
swift-marshal check
# Apply fixes
swift-marshal fixExample output:
Sources/App/Models/User.swift:
struct User (line 3)
[needs reordering]
original:
- instance_method fullName
- instance_property firstName
- initializer init
reordered:
- initializer init
- instance_property firstName
- instance_method fullName
✗ 1 type in 1 file needs reordering
Run 'swift-marshal fix' to apply changesConfiguration
Drop a .swift-marshal.yaml in the project root to control member order, paths, and extension handling:
version: 1
ordering:
members:
- typealias
- associatedtype
- initializer
- type_property
- instance_property
- subtype
- type_method
- instance_method
- subscript
- deinitializer
extensions:
strategy: separate
respect_boundaries: true
paths:
- Sources/Full reference in the Usage & Configuration Guide.
Documentation
| Document | Description | |---|---| | Installation | Homebrew, binary, source, pre-commit hook, Xcode plugin | | Usage & Configuration | CLI options, YAML config, output formats, CI integration | | Architecture | Module map, pipeline design, configuration model, AST rewriting | | Codebase Reference | Every type, protocol, and stage documented |
Package Metadata
Repository: ericodx/swift-marshal
Default branch: main
README: README.md