Swinject
Resolver
Our great sponsors
Swinject | Resolver | |
---|---|---|
6 | 11 | |
6,178 | 2,094 | |
0.7% | - | |
4.2 | 2.8 | |
6 days ago | 11 days ago | |
Swift | Swift | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Swinject
-
Dependency Injection Simplified
DI is a concept which makes a class independent of its dependency management. It achieves that by decoupling the usage of an object from its creation. This helps you to follow SOLID’s dependency inversion and single responsibility principles. To achieve this in Swift one of the most appreciated library is Swinject. This library not only provides DI but also have many other features like:-
-
Awesome macOS Libraries List
Swinject - Dependency injection framework for Swift. Language: Swift.
-
SwiftUI Dependency injection
We use Swinject which is probably quite similar https://github.com/Swinject/Swinject
- Any DI libraries for swift?
- How do you guys see PHP and its framworks/CMS in 2025?
-
How to modularize a big iOS project
So, how do we fix this? There is a cleaner solution. By using a dependency injection framework, such as Swinject we can create a base module that we might call the DI module.
Resolver
-
On using Dependency Injection with MVVM
If you're looking in to using a framework instead of doing it manually, I prefer Resolver over Swinject but both will work.
-
Popularity of unit tests with employers
But, today, I use Resolver. And recommend others also use this. There are other approaches, but Resolver is quite good. It solves this problem. "Just pass stuff in to the constructor" isn't true dependency injection anyway (but it kinda works, it's just a huge mess).
-
UIKIT Global class / environment object equivalent
You can achieve the concept as the environment in SwiftUI using protocols and Resolver https://github.com/hmlongco/Resolver
-
Dependency injection tutorial
This isn't a full tutorial, but it's a great Swift dependency injection library with lots of information in its documentation: https://github.com/hmlongco/Resolver
-
Fusion: A lightweight, @propertyWrapper based dependency injection library for Swift
I also suggest Resolver
-
MVVM + Dependency Injection
Sounds ok, and for DI I can recommend this lib, works well and easy to use https://github.com/hmlongco/Resolver/
-
SwiftUI Dependency injection
We’re using Resolver for dependency injection. Check it out: https://github.com/hmlongco/Resolver
- Add SPM dependency without exposing to clients?
- Any DI libraries for swift?
-
How to update a boolean in one view model from another view model?
Since multiple ViewModels need to access this data, I would avoid storing the data in a particular ViewModel—which should correlate only with a single, specific View—and instead implement this behavior in a third object (such as an AuthenticationService class). This way, both/any of your subsequent Views and ViewModels alike can all access that object as a single source of truth (by passing it around explicitly, putting it in the environment, or my favorite method: Resolver). Just remember to think about who should “own” data!
What are some alternatives?
Cleanse - Lightweight Swift Dependency Injection Framework
Needle - Compile-time safe Swift dependency injection framework
Typhoon - Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Weaver - Dependency Injection framework for Swift (iOS/macOS/Linux)
Dip - Simple Swift Dependency container. Use protocols to resolve your dependencies and avoid singletons / sharedInstances!
DIKit - Dependency Injection Framework for Swift, inspired by KOIN.
Kraken - Simple Dependency Injection container for Swift. Use protocols to resolve dependencies with easy-to-use syntax!
Locatable - A micro-framework that leverages Swift Property Wrappers to implement the Service Locator pattern
EasyDi - Effective DI library for rapid development in 200 lines of code.
Corridor - A Coreader-like Dependency Injection μFramework