builder

1.0.2

Builder Patterns for Flexible Syntax in Swift
pelagornis/builder

What's New

Builder 1.0.2

2023-10-11T14:01:03Z

What's Changed

  • Support Swift Version: 5.7 -> 5.9
  • Builder Library Support Macro
  • Macro Docc Support
@Builder
struct Person {
   var name: String?
   var age: Int?
}

let team = Person()
   .builder()
   .name("Jihoon")
   .age(20)
   .build()

Builder

Official SPM Swift License Platform

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.

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/pelagornis/builder.git", from: "1.0.1")
    ],
    ...
)

Then import the Builder from thr location you want to use.

import Builder

Documentation

The documentation for releases and main are available here:

Using

Initializer UIView with Builder

let view = UIView()
             .builder()
             .translatesAutoresizingMaskIntoConstraints(false)
             .backgroundColor(.systemBlue)
             .build()

This is equivalent to

let view: UIView = {
    let view = UIView()
    view.translatesAutoresizingMaskIntoConstraints = false
    view.backgroundColor(.systemBlue)
    return view
}()

Support Macro

Starting with Swift version 5.9, @Builder macro is supported.

@Builder
struct Pelagornis {
    var libraryName: String?
}

License

Builder is under MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Mon Jan 29 2024 13:42:43 GMT-1000 (Hawaii-Aleutian Standard Time)