{"id":26275726,"url":"https://github.com/hainayanda/builder","last_synced_at":"2025-05-06T16:05:07.494Z","repository":{"id":37613751,"uuid":"396367324","full_name":"hainayanda/Builder","owner":"hainayanda","description":"Builder is Swift builder pattern library that utilize dynamicCallable and dynamicMemberLookup as its core.","archived":false,"fork":false,"pushed_at":"2023-06-19T03:44:56.000Z","size":270,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T23:04:29.137Z","etag":null,"topics":["builder","builder-design-pattern","builder-pattern","cocoapods","swift","swiftpackagemanager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hainayanda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-15T13:53:00.000Z","updated_at":"2024-10-15T14:52:19.000Z","dependencies_parsed_at":"2025-03-14T10:27:53.607Z","dependency_job_id":null,"html_url":"https://github.com/hainayanda/Builder","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainayanda%2FBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainayanda%2FBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainayanda%2FBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hainayanda%2FBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hainayanda","download_url":"https://codeload.github.com/hainayanda/Builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252720332,"owners_count":21793737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder","builder-design-pattern","builder-pattern","cocoapods","swift","swiftpackagemanager"],"created_at":"2025-03-14T10:17:44.447Z","updated_at":"2025-05-06T16:05:07.463Z","avatar_url":"https://github.com/hainayanda.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"512\" height=\"192\" src=\"builder.png\"/\u003e\n\u003c/p\u003e\n\n# Builder\n\nBuilder is Swift builder pattern library that utilize dynamicCallable and dynamicMemberLookup as its core.\n\n[![codebeat badge](https://codebeat.co/badges/2aadfe57-5ebc-4c9d-a76a-ac59ebb94b8d)](https://codebeat.co/projects/github-com-hainayanda-builder-main)\n![build](https://github.com/hainayanda/Builder/workflows/build/badge.svg)\n![test](https://github.com/hainayanda/Builder/workflows/test/badge.svg)\n[![SwiftPM Compatible](https://img.shields.io/badge/SwiftPM-Compatible-brightgreen)](https://swift.org/package-manager/)\n[![Version](https://img.shields.io/cocoapods/v/Builder.svg?style=flat)](https://cocoapods.org/pods/Builder)\n[![License](https://img.shields.io/cocoapods/l/Builder.svg?style=flat)](https://cocoapods.org/pods/Builder)\n[![Platform](https://img.shields.io/cocoapods/p/Builder.svg?style=flat)](https://cocoapods.org/pods/Builder)\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\n- Swift 5.1 or higher (or 5.3 when using Swift Package Manager)\n- iOS 10 or higher\n- macOS 10.10 or higher\n- tvOS 10 or higher\n- watchOS 4 or higher\n\n## Installation\n\n### Cocoapods\n\nBuilder is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your Podfile:\n\n```ruby\npod 'Builder', '~\u003e 1.1.1'\n```\n\n### Swift Package Manager from XCode\n\n- Add it using XCode menu **File \u003e Swift Package \u003e Add Package Dependency**\n- Add **https://github.com/hainayanda/Builder.git** as Swift Package URL\n- Set rules at **version**, with **Up to Next Major** option and put **1.1.1** as its version\n- Click next and wait\n\n### Swift Package Manager from Package.swift\n\nAdd as your target dependency in **Package.swift**\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/hainayanda/Builder.git\", .upToNextMajor(from: \"1.1.1\"))\n]\n```\n\nUse it in your target as `Builder`\n\n```swift\n .target(\n  name: \"MyModule\",\n  dependencies: [\"Builder\"]\n)\n```\n\n## Author\n\nNayanda Haberty, hainayanda@outlook.com\n\n## License\n\nImpose is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n## Basic Usage\n\nUsing Builder is simple. You just need to pass the object you want to build and assign its writable property as its a function. Example:\n\nIf you have a class like this:\n\n```swift\nclass MyObject {\n    var string: String?\n    var int: Int?\n    var double: Double?\n    \n    ...\n    ...\n}\n```\n\nyou can build it like this:\n\n```swift\nlet myObject: MyObject = builder(MyObject())\n    .string(\"some string\")\n    .int(10)\n    .double(1.2)\n    .build()\n```\n\nIts even can assign property of property as deep as you need, as long the property is mutable:\n\n```swift\nlet myObject: MyObject = builder(MyObject())\n    .string(\"some string\")\n    .int(10)\n    .double(1.2)\n    .subObject.string(\"some string\")\n    .subObject.int(10)\n    .subObject.double(1.2)\n    .build()\n```\n\n## Buildable\n\nThere's a protocol named Buildable that allowed your object to have a `bld` computed property that will return a Builder object for you to use:\n\n```swift\nlet myObject: MyObject = MyBuildable().bld\n    .string(\"some string\")\n    .int(10)\n    .double(1.2)\n    .subObject.string(\"some string\")\n    .subObject.int(10)\n    .subObject.double(1.2)\n    .build()\n```\n\n## Initializable\n\nThere's a protocol named Initializable which declared like this:\n\n```swift\npublic protocol Initializable {\n    init()\n}\n```\n\nits just to ensure you can call builder global function by only passing its `Type`:\n\n```swift\nlet view: MyObjectImplementInitializable = builder(MyObjectImplementInitializable.self)\n    .string(\"some string\")\n    .int(10)\n    .double(1.2)\n    .build()\n```\n\nInitializable is implementing Buildable by default\n\n## Error Handling\n\nSometimes you can mistakenly  try to assigning property that immutable. By default you can always see the debugPrint output like this:\n\n```\nFailed to assign property keypath of MyType with property type MyPropertyType because its not writable\n```\n\nBut it can be forgotton and became a bug in the future. So you can always force it to throw fatalError if something like this is happes by assigning `errorHandling` on `BuilderConfig`:\n\n```swift\nBuilderConfig.errorHandling = .fatalErrorOnAssigningLet\n```\n\nit will create a fatal error when immutable property is assigned, so you can always fix it before it became a problem in the future. \nYou can always handling it manually by assigning closure:\n\n```swift\nBuilderConfig.errorHandling = .manual { message in\n    debugPrint(\"FIX THIS: \\(message)\")\n}\n```\n\n## Contribute\n\nYou know how, just clone and do pull request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhainayanda%2Fbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhainayanda%2Fbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhainayanda%2Fbuilder/lists"}