✅ Tiny footprint (Injector.swift and Factory.swift are the only source files).
✅ Built for mocking in UnitTests, UITests and SwiftUI previews.
✅ Unit Tested.
✅ Cool logo.
Usage
Injector uses the concept of a syringe:
extension Syringe {
}
Filled with medicine:
extension Syringe {
static let person = Medicine<PersonType>(Person(), mock: Person_Mock())
static let dog = Medicine<DogType>(Dog(), mock: Dog_Mock())
}
And at runtime injected:
let person = Syringe.person.inject()
// or
let person = Syringe.person()
// or
@Inject(Syringe.person) var person
A Swift package for simple dependency injection that also supports Swift UI previews.
Features
Injector.swift
andFactory.swift
are the only source files).Usage
Injector uses the concept of a syringe:
Filled with medicine:
And at runtime injected:
Performing a clean will reset the instances:
Installation
SPM