{"id":16221541,"url":"https://github.com/wilbertliu/gluten","last_synced_at":"2025-06-13T11:08:33.241Z","repository":{"id":56912805,"uuid":"87901644","full_name":"wilbertliu/Gluten","owner":"wilbertliu","description":"Micro library to unify XIB and its code.","archived":false,"fork":false,"pushed_at":"2017-09-18T04:13:22.000Z","size":19,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-13T11:08:11.460Z","etag":null,"topics":["abstraction","ios","reusable-view","swift","xib"],"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/wilbertliu.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}},"created_at":"2017-04-11T07:08:40.000Z","updated_at":"2023-07-18T12:11:48.000Z","dependencies_parsed_at":"2022-08-20T20:50:23.938Z","dependency_job_id":null,"html_url":"https://github.com/wilbertliu/Gluten","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wilbertliu/Gluten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilbertliu%2FGluten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilbertliu%2FGluten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilbertliu%2FGluten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilbertliu%2FGluten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilbertliu","download_url":"https://codeload.github.com/wilbertliu/Gluten/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilbertliu%2FGluten/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259634375,"owners_count":22887699,"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":["abstraction","ios","reusable-view","swift","xib"],"created_at":"2024-10-10T12:08:41.824Z","updated_at":"2025-06-13T11:08:33.205Z","avatar_url":"https://github.com/wilbertliu.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gluten\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Build Status](https://travis-ci.org/wilbertliu/Gluten.svg?branch=master)](https://travis-ci.org/wilbertliu/Gluten)\n[![Coverage Status](https://coveralls.io/repos/github/wilbertliu/Gluten/badge.svg?branch=master)](https://coveralls.io/github/wilbertliu/Gluten?branch=master)\n\nUnify XIB with its code.\n\n## Background\n\nWe always try to generalize some views that would be used in different places throughout the app.\nAnd one approach that we usually do is to make XIB along with its code.\n\nBut as we know, the XIB and its code don't automatically *connected*.\nAnd we tend do these things to make them connected :\n1. Instantiate the NIB.\n2. Add the loaded NIB as a subview.\n3. Setting frame or constraints needed.\n\nAlways doing those things for every view that we make, I think there's a better way.\nWhat we have to do is calling one function inside our view's code. Yes, just that!\nFollow the steps below to see how it goes.\n\n## Installation\n\n### Carthage\n\n```\ngithub \"wilbertliu/Gluten\"\n```\n\n### CocoaPods\n\nAdd the following line into the `Podfile` :\n\n```\npod 'Gluten'\n```\n\nAfter that, run the following command :\n\n```\n$ pod install\n```\n\n## Usage\n\nBecause `Gluten` was created in extension, we don't need to `import` anything.\nJust call `glueSourceAndView()` function inside our view's code. Here's an example :\n\n```swift\nimport UIKit\n\nclass ReusedView: UIView {\n    override init(frame: CGRect) {\n        super.init(frame: frame)\n        glueSourceAndView()\n    }\n\n    required init?(coder aDecoder: NSCoder) {\n        super.init(coder: aDecoder)\n        glueSourceAndView()\n    }\n\n    init() {\n        super.init(frame: CGRect.zero)\n        glueSourceAndView()\n    }\n}\n```\n\nNote that when we have a class named `ReusedView`, the XIB name must be the same.\n**When you're not doing so, `Gluten` would leave those XIB and code unconnected.**\n\n## Support\n\nIf you have any feedbacks, feel free to submit a PR! And I'm more than happy to answer your\nquestions, or maybe just some hi?! To do that, shoot me a DM or tweet [@wilbertliu](https://twitter.com/wilbertliu)\n\n## License\n\nMIT © Wilbert Liu\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilbertliu%2Fgluten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilbertliu%2Fgluten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilbertliu%2Fgluten/lists"}