{"id":16224141,"url":"https://github.com/riteshhgupta/rgdependencyinjector","last_synced_at":"2026-07-22T18:31:24.030Z","repository":{"id":83568459,"uuid":"110705389","full_name":"riteshhgupta/RGDependencyInjector","owner":"riteshhgupta","description":"RGDependencyInjector is a protocol oriented dependency injection µ-framework for iOS.","archived":false,"fork":false,"pushed_at":"2018-11-13T17:17:36.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T21:33:46.702Z","etag":null,"topics":["cocoapods","dependency-injection","ios","protocol","swift","xcode"],"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/riteshhgupta.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-11-14T15:06:00.000Z","updated_at":"2018-06-26T11:00:55.000Z","dependencies_parsed_at":"2023-07-07T19:32:24.054Z","dependency_job_id":null,"html_url":"https://github.com/riteshhgupta/RGDependencyInjector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/riteshhgupta/RGDependencyInjector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riteshhgupta%2FRGDependencyInjector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riteshhgupta%2FRGDependencyInjector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riteshhgupta%2FRGDependencyInjector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riteshhgupta%2FRGDependencyInjector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riteshhgupta","download_url":"https://codeload.github.com/riteshhgupta/RGDependencyInjector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riteshhgupta%2FRGDependencyInjector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35773465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cocoapods","dependency-injection","ios","protocol","swift","xcode"],"created_at":"2024-10-10T12:22:41.981Z","updated_at":"2026-07-22T18:31:24.010Z","avatar_url":"https://github.com/riteshhgupta.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RGDependencyInjector\n\n## Depedency Injection\n\n`Dependency Injection` is a style of object configuration in which an object's properties are set by an external entity. In other words objects are configured by an external entity, which is an alternative to having the object configure itself. You can read more about it in one of [Martin Fowler's articles](https://www.martinfowler.com/articles/injection.html)!\n\n## About\n\n`RGDependencyInjector` lets you inject dependencies in a `class` which is otherwise difficult to initialize due to framework limitations. It uses a protocol based approach which makes it easy to **adopt** and **extend**. There's no magic happening of any sort anywhere, it's a very lightweight µ-framework which you can browse easily!\n\n## Example\n\nLet's say we have a class `ViewController` which is expecting an outside entity to set it's `items` property. To achieve this, we need to make `ViewController` implement `InjectableController` protocol. `InjectableController` is a generic protocol which expects a `Dependency` type, in this case it's `ViewControllerDependency` which has all the properties required by `ViewController`.\n\n```swift\nfinal class ViewController: UIViewController {\n\n\t// dependent property, which needs to be configured from outside\n\tvar items: [String]!\n\t...\n}\n\nextension ViewController: InjectableController {\n\n\t// it lets you define a model which represents the dependency\n\ttypealias Dependency = ViewControllerDependency\n\n\t// this is where you can hookup all the dependencies/bindings\n\tfunc inject(_ dependency: ViewControllerDependency) {\n\t\titems = dependency.items\n\t}\n\n\t// these two properties are required to get a controller's instance from a storyboard\n\tstatic var storyboardName: String { return \"Main\" }\n\tstatic var storyboardId: String { return \"ViewController\" }\n}\n\n// model which represents ViewController's dependency\nstruct ViewControllerDependency {\n\n\tlet items: [String]\n}\n```\n \nOnce we are done with the implementation, we get a simple api to get an instance which has all the injected properties,\n\n```swift\n// create the dependency\nlet fruits = [\"apple\", \"banana\", \"orange\"]\nlet dependency = ViewControllerDependency(items: fruits)\n\n// inject the above dependency into `injectableInstance(:)`\nlet controller = ViewController.injectableInstance(dependency: dependency)\n\n```\n\n`ViewController.injectableInstance(dependency: dependency)` is the final api which will return the required controller with injected properties.\n\n## Custom Injectors\n\nIf you are interested in making custom injectors to suit your needs then you simply need to make a new protocol which should inherit `Injectable`, e.g.\n\n```\nprotocol InjectableViewModel: Injectable {\n\t...\n}\n```\n\n## Installation\n\n### Cocoapods\n\nTo integrate RGDependencyInjector into your Xcode project using CocoaPods, specify it in your Podfile,\n\n```\n  pod 'RGDependencyInjector', :git =\u003e 'https://github.com/riteshhgupta/RGDependencyInjector.git'\n```\n\n## Contributing\n\nContributions are welcome and encouraged! Open an [issue](https://github.com/riteshhgupta/RGDependencyInjector/issues/new) or submit a [pull request](https://github.com/riteshhgupta/RGDependencyInjector/compare) 🚀\n\n## Licence\n\nRGDependencyInjector is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friteshhgupta%2Frgdependencyinjector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friteshhgupta%2Frgdependencyinjector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friteshhgupta%2Frgdependencyinjector/lists"}