Is there any good dependency injection library?

Hi,

I’ve recently tried to achieve dependency injection pattern in iOS app. As a developer with asp.net background I have used many c# libraries like Structuremap and Autofac. The bright side of using these is that all dependencies are injected directly via constructor without any need to use service locator anti-pattern.
Making long things short: I’ve tried to achieve the same behavior in iOS app using Swinject. However, while in “normal” classes dependencies are resolved just fine for ViewControllers it is necessary to inject them manually like this:
registration.swift · GitHub

For me it is clear usage of service locator anti pattern and it would be nice not having these lines at all. Is there any library which make this done? I wonder how should it work? Maybe overriding ViewController creation mechanism? I don’t know anything about reflection in Swift but maybe that way should work.

Hi @rylek90,
Have you looked at Typhoon (however it has not been updated to Swift4) then there is Swinject and Cleanse (which is inspired by Dagger and Guice)

cheers,

Jayant