Episode #460

Dependency Injection with Resolver

23 minutes
Published on September 11, 2020

This video is only available to subscribers. Get access to this video and 586 others.

Managing dependencies can be a pain. Unless you're using shared instances accessible everywhere, you end up having to pass along dependencies from class to class. One strategy for decoupling your types from external dependencies is to create protocols and "inject" the actual concrete implementations at runtime. This enables you to test them easily and also isolates library-specific APIs from the rest of your application. This can make switching between libraries more feasible. In this episode we'll take a look at a library called Resolver that does this. Technically it implements Service Location rather than Dependency Injection, but the result is similar.

This episode uses Swift 5.2, Xcode 12-beta6.