A compile-time-safe dependency injection library for Swift that eliminates boilerplate while ensuring dependency validity.
SafeDI is a compile-time-safe dependency injection library for Swift projects. It reads your code, validates dependencies, and generates a dependency tree during compilation, ensuring that if your code compiles, your dependency tree is valid. It eliminates the boilerplate of manual dependency injection while maintaining safety and simplicity.
Swift developers building iOS, macOS, or server-side applications who want a safe, scalable dependency injection solution without runtime overhead. It's particularly useful for teams maintaining large, multi-module Swift codebases.
Developers choose SafeDI because it offers compile-time safety and hierarchical dependency scoping without requiring DI-specific types or maintaining separate containers. Unlike other libraries, it provides safety similar to manual injection with zero boilerplate and clear error messages.
Compile-time-safe dependency injection for Swift without the boilerplate
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Validates all dependencies during compilation, eliminating runtime injection errors and ensuring a valid dependency tree if the code compiles, as emphasized in the README's core concept.
Supports scoped dependencies within a hierarchical tree, ideal for managing context-specific resources like authentication tokens across modules, a feature highlighted in comparisons with other DI libraries.
Works seamlessly across multiple Swift modules with configuration via #SafeDIConfiguration, as shown in the examples for Xcode projects and Swift packages.
Generates memberwise initializers for every @Instantiable type, simplifying unit test setup without manual boilerplate, a key feature listed in the README.
Requires integrating a code generation plugin and configuring macros, which can be cumbersome for custom build systems or multi-project setups, as noted in the 'Generating your dependency tree' section.
Only supports Swift 6.3 and later, locking out legacy projects and forcing migration efforts, as stated in the migration guide from 1.x to 2.x.
The migration from 1.x to 2.x involved significant API changes, dropped CocoaPods support, and replaced CSV configuration, indicating potential future instability.