Skip to content

pelagornis/swift-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Jihoonahn
May 10, 2023
6cf4a26 · May 10, 2023

History

8 Commits
May 10, 2023
May 10, 2023
May 10, 2023
May 10, 2023
May 10, 2023
May 10, 2023
May 10, 2023

Repository files navigation

Builder

Swift

Builder Patterns for Flexible Syntax in Swift

Requirements

  • iOS 11.0+ / macOS 10.13+ / tvOS 11.0+ / watchOS 4.0+
  • Swift 5.8+

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.0")
    ],
    ...
)

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

import Builder

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
}()

License

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