Needle is a dependency injection (DI) system for Swift. 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 changes with confidence. If it compiles, it works. In this aspect, Needle is more similar to Android Dagger.
The linked document uses a somewhat real example to explain what the dependency injection pattern is, and its benefits.
Using and integrating with Needle has three steps. Each of the following steps has detailed instructions and explanations in the linked documents.
- Include
NeedleFoundation
module in your Swift project. - Integrate Needle's code generator with your Swift project.
- Write application DI code following NeedleFoundation's API.