A Swift dependency management library inspired by SwiftUI's environment
open sourceMITfree
swift-dependencies is Point-Free's dependency management (dependency injection) library for Swift, inspired by SwiftUI's environment. It controls the parts of an app that talk to the outside world (API clients, UUID and Date initializers, file access, user defaults, clocks and timers) so they can be swapped for test, preview and live implementations, making tests fast and deterministic and previews reliable. It was designed over a series of Point-Free episodes and comes with companion packages such as combine-schedulers and xctest-dynamic-overlay.
Problems it solves
- inject dependencies in a SwiftUI app
- make Swift tests deterministic by controlling dates and network calls
- swap API clients for previews in Swift
Features
- SwiftUI environment-style dependency management
- swap live, test and preview implementations
- controls dates, UUIDs, clocks, files and API clients
- deterministic tests
Alternatives
The same job
These do what swift-dependencies does.
- Factory (Swift) Container-based dependency injection for Swift and SwiftUI
