A Swift library that simplifies implementing Pure Dependency Injection (DI) without a DI container.
Pure is a Swift library that facilitates Pure Dependency Injection (DI) in Cocoa applications. It helps developers implement DI without a DI container by structuring dependency composition in the Composition Root, making applications more testable and maintainable.
iOS and macOS developers building Cocoa applications who want to implement clean, testable dependency injection without relying on external DI containers.
Pure offers a lightweight, protocol-driven approach to DI that enforces explicit dependency composition, reduces framework overhead, and enhances testability compared to container-based DI solutions.
Pure DI in Swift
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Pure enables easy testing of AppDelegate and other components by allowing dependency injection and environment separation, as demonstrated in the README's testing examples for production vs. testing environments.
It eliminates the need for a DI container, reducing framework dependencies and potential performance issues associated with container resolution, aligning with Pure DI principles.
Provides protocols like FactoryModule and ConfiguratorModule to generalize factories and configurators, making dependency management more organized and reusable, as shown in the Dependency and Payload types.
Offers customization for Storyboard and URLNavigator support, enabling seamless integration with existing Cocoa development patterns, detailed in the Customizing section.
Setting up dependencies requires explicit struct definitions and manual composition in the Composition Root, which can lead to verbose and repetitive code, especially for complex object graphs, as acknowledged in the Problem section.
Compared to full-fledged DI containers, Pure lacks features like automatic dependency resolution, lifetime scoping, or AOP support, which might be needed in more complex scenarios beyond basic injection.
Developers unfamiliar with Pure DI concepts or the Composition Root pattern may find it challenging to adopt, as it requires a different mindset from container-based DI, with concepts like lazy dependencies adding complexity.