SwiftのDIコンテナは何がデファクト?使い所は?
使わないのが普通らしい(?)
Dip
Swinject
多分一番スターが多い
Pure Swift
Typhoon
Objective-C時代からある
Cleanse
Swinjectより設計の筋が良さそう
深く見ていないので断定は不能
Square
Cleanse is a dependency injection framework for Swift. It is designed from the ground-up with developer experience in mind. It takes inspiration from both Dagger and Guice. Root componentがあり、依存物をもつ形式
Root componentにはhow we construct every object/dependency in our app.の手続きを書く
configureRootはBindingReceipt<RootViewController>を返す
RootViewControllerクラスを作成してBinderに食わせる
サンプルがAppDelegate。これはSwitfUI以前のUIKit App Delegate形式のもの
Needle
Unlike other DI frameworks, such as Cleanse, Swinject, Needle encourages hierarchical DI structure and utilizes code generation to ensure compile-time safety.
This allows us to develop our apps and make code changes with confidence. If it compiles, it works.
2021-02-24 こちらもSwiftUIのサンプルはない
componentを使うことでバケツリレーを回避できる
参考