# DITranquillity Tranquillity is a lightweight but powerful [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) library for swift. The name "Tranquillity" laid the foundation in the basic principles of library: clarity, simplicity and security. It says - use the library and you will be calm for your dependencies. > Language switch: [English](README.md), [Russian](README_ru.md) ## About Dependendy Injection Dependency Injections is a software design pattern in which someone delivers dependencies to an object. Is one form of the broader technique of [Inversion Of Control](https://en.wikipedia.org/wiki/Inversion_of_control) and help the [Dependency Inversion Principle](https://en.wikipedia.org/wiki/Dependency_inversion_principle) [For more details you can read this link](Documentation/en/about_dependency_injection.md) Also I recommend you to read [Glossary](Documentation/en/glossary.md) which will help to better understand the terms. ## Features #### Core - [x] [Registration components and services](Documentation/en/core/registration_and_service.md) - [x] [Initializer/Property/Method Injections](Documentation/en/core/injection.md) - [x] [Optional and argument, many, by tag Injections](Documentation/en/core/modificated_injection.md) - [x] [Delayed injection](Documentation/en/core/delayed_injection.md) - [x] [Circular dependency injection](Documentation/en/core/injection.md) - [x] [Scope and lifetime](Documentation/en/core/scope_and_lifetime.md) - [x] [Modular](Documentation/en/core/modular.md) - [x] [Details logs](Documentation/en/core/logs.md) - [x] Thread safety - [x] [Container hierarchy](Documentation/en/core/container_hierarchy.md) #### UI - [x] [Storyboard and StoryboardReferences](Documentation/en/ui/storyboard.md) - [x] [Simple subviews and Cells Injection](Documentation/en/ui/view_injection.md) #### Graph API - [x] [Get dependency graph](Documentation/en/graph/get_graph.md) - [x] [Graph Validation](Documentation/en/graph/graph_validation.md) - [ ] [Visualization dependency graph](Documentation/en/graph/visualization_graph.md) ## Installing The library supports three popular package managers: Cocoapods, Carthage, SwiftPM. #### CocoaPods Add the following lines to your `Podfile`: ``` pod 'DITranquillity' ``` #### SwiftPM You can use "Xcode/File/Swift Packages/Add Package Dependency..." and write github url: ``` https://github.com/ivlevAstef/DITranquillity ``` Also you can edit your `Package.swift` and the following line into section `dependencies`: ```Swift .package(url: "https://github.com/ivlevAstef/DITranquillity.git", from: "4.5.2") ``` And don't forget to specify in your section `target` wrote dependency line: ```Swift .product(name: "DITranquillity") ``` > Attention! - SwiftPM unsupport features from the "UI" section. #### Carthage Add the following lines to your `Cartfile`: ``` github "ivlevAstef/DITranquillity" ``` Carthage support "UI" and "GraphAPI" section no additional actions. ## Usage The library uses a declarative style of dependency description, and allows you to separate your application code from dependency description code. For a quick entry, let's look at an example code of one simplified VIPER screen: ```Swift ................................................. /// Dependency description let container = DIContainer() container.register(LoginRouter.init) container.register(LoginPresenterImpl.init) .as(LoginPresenter.self) .lifetime(.objectGraph) container.register(LoginViewController.init) .injection(cycle: true, \.presenter) .as(LoginView.self) .lifetime(.objectGraph) container.register(AuthInteractorImpl.init) .as(AuthInteractor.self) ................................................. /// Application start point let router: LoginRouter = container.resolve() window.rootViewController = router.rootViewController router.start() ................................................. /// Application Code import SwiftLazy class LoginRouter { let rootViewController = UINavigationController() private let loginPresenterProvider: Provider