https://github.com/pelagornis/swift-builder
Builder Patterns for Flexible Syntax in Swift.
https://github.com/pelagornis/swift-builder
builder-design-pattern builder-pattern macro pelagornis swift
Last synced: 2 months ago
JSON representation
Builder Patterns for Flexible Syntax in Swift.
- Host: GitHub
- URL: https://github.com/pelagornis/swift-builder
- Owner: pelagornis
- License: mit
- Created: 2023-05-10T10:49:12.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-14T04:54:10.000Z (12 months ago)
- Last Synced: 2025-12-13T00:51:44.488Z (5 months ago)
- Topics: builder-design-pattern, builder-pattern, macro, pelagornis, swift
- Language: Swift
- Homepage:
- Size: 324 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Builder



[](https://github.com/pelagornis/swift-builder/blob/main/LICENSE)

Builder Patterns for Flexible Syntax in Swift
## Installation
Builder was deployed as Swift Package Manager. Package to install in a project. Add as a dependent item within the swift manifest.
```swift
let package = Package(
...
dependencies: [
.package(url: "https://github.com/pelagornis/swift-builder.git", from: "1.1.0")
],
...
)
```
Then import the Builder from thr location you want to use.
```swift
import Builder
```
And then adding the product to any target that needs access to the library:
```swift
.product(name: "Builder", package: "swift-builder"),
```
## Documentation
The documentation for releases and ``latest`` are available here:
- [``latest``](https://pelagornis.github.io/swift-builder/latest/documentation/builder)
## Using
Initializer UIView with ``Builder``
```swift
let view = UIView()
.builder()
.translatesAutoresizingMaskIntoConstraints(false)
.backgroundColor(.systemBlue)
.build()
```
This is equivalent to
```swift
let view: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor(.systemBlue)
return view
}()
```
Want to use with your own types? Just make extensions.
```swift
extension MyType: Buildable {}
let instance = MyType()
.builder()
.property("some value")
.build()
```
## Support Macros
`@Builder` macro is supported.
```swift
@Builder
struct Pelagornis {
var libraryName: String?
}
```
## License
**Builder** is under MIT license. See the [LICENSE](LICENSE) file for more info.