1
1
# InfomaniakDI
2
2
3
+ [ ![ ] ( https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FInfomaniak%2Fswift-dependency-injection%2Fbadge%3Ftype%3Dswift-versions )] ( https://swiftpackageindex.com/Infomaniak/swift-dependency-injection )
4
+ [ ![ ] ( https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FInfomaniak%2Fswift-dependency-injection%2Fbadge%3Ftype%3Dplatforms )] ( https://swiftpackageindex.com/Infomaniak/swift-dependency-injection )
5
+
3
6
Minimalist dependency injection mechanism written in pure Swift.
4
7
5
- ## Abstract
6
- Register factories thanks to the ` Factory ` type into the resolver.
7
- Use the property wrapper ` @InjectService ` to resolve a shared instance from any queue.
8
+ Support any first party Swift platfom. [ iOS / iPadOS / watchOS / macOS / Linux ]
9
+
10
+ Well tested. Used in production across the Infomaniak iOS Apps.
11
+
12
+ Property wrapper based with ` @LazyInjectService ` and ` @InjectService ` .
13
+
14
+ Optimised to work well with SwiftUI Views.
8
15
9
16
## Features
17
+ - [x] Efficient SwiftUI. ` @(Lazy)InjectService ` will not re-resolve, when used as a property, on a ` View ` redraw.
18
+ - [x] Good integration test coverage
10
19
- [x] Pure Swift Type Support
11
20
- [x] Thread safety
12
21
- [x] Injection by name
13
22
- [x] Injection with Arguments
14
- - [x] Integration tests
15
23
- [x] Lazy init (with @LazyInjectService )
16
- - [x] Efficient SwiftUI with ` @LazyInjectService ` and ` @InjectService ` used as IVAR in ` View `
17
-
18
- ## OS Support
19
-
20
- Anything with first party Swift support. (iOS / macOS / Linux …)
21
24
22
25
## Roadmap
23
26
- [ ] Optionals
24
27
- [ ] Multiple containers
25
28
26
29
## Requirements
27
- - Swift 5.x +
30
+ - Swift 5.6 +
28
31
- SPM
29
32
30
- ## Usage
33
+ ## Setup
31
34
32
35
Early on in the lifecycle of your app, you want to write something like this :
33
36
@@ -52,7 +55,11 @@ later on, when you want to resolve a service use the property wrapper like so:
52
55
``` swift
53
56
@InjectService var injected: SomeService
54
57
```
55
- Injection will be performed at the init time of the owner of the property.
58
+ Injection will be performed at the init time of the owner of the property.
59
+
60
+ Use ` @LazyInjectService ` for resolution at first use of the wrapped property. Prefer ` @LazyInjectService ` when used as a property.
61
+
62
+ ## Documentation
56
63
57
64
Checkout ` ITSimpleReslover.swift ` for more advanced examples.
58
65
0 commit comments