You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would call it a very elaborated proof of concept, though we use it in production atm.
6
-
We are open for every kind of feedback, improvements of the generated code/templates, discussion of the input format etc.
7
-
8
5
## TLDR;
9
6
10
-
We propose a method to get rid of duplicate use of class values and namestrings, by generating explicit functions for registering and resolving.
7
+
Swinject-CodeGen provides a method to get rid of duplicate use of class values and namestrings, by generating explicit functions for registering and resolving using Swinject.
11
8
Doing this, we also can generate typed tuples to use when resolving, thus allowing better documented and less error-prone code.
12
9
13
10
## Installation
14
-
15
-
We aim to support carthage in the near future
16
-
17
11
### Cocoapods
18
12
19
13
Add
@@ -24,24 +18,38 @@ pod 'Swinject-CodeGen', :git => 'https://github.com/Swinject/Swinject-CodeGener
24
18
25
19
to your podfile.
26
20
21
+
### Carthage
22
+
23
+
Add
24
+
25
+
```
26
+
github "Swinject/Swinject-CodeGeneration"
27
+
```
28
+
29
+
to your Cartfile.
30
+
27
31
## Integration
28
32
1. Define your dependencies in a .csv or .yml file (see below and example file)
29
33
2. Add a call to generate the code as build script phase:
The resulting extension files are added to xcode and given appropriate target settings.
236
-
237
239
## Migration
238
240
The script also generates migration.sh files (when using the -m switch), which use sed to go through the code and replace simple cases (i.e. no arguments) of resolve and register.
239
241
No automatic migration is available for cases with arguments, yet.
240
242
Simply call the .sh file from the root of the project and compare the results in a git-GUI.
241
243
242
244
## Results
243
-
We currently use the code generation in a medium-sized app, with a total of ~130 lines of definitions across 3 .csv files (shared definitions, iOS only, tvOS only).
244
-
We found our code to become much more convenient to read and write, due to reduced duplication and autocompletion. We also have a much better overview the classes available through dependency injection.
245
+
We currently use the code generation in two medium-sized apps across tvOS and iOS.
246
+
247
+
We found our code to become much more convenient to read and write, due to reduced duplication and autocompletion.
248
+
We also have a much better overview the classes available through dependency injection.
245
249
Changing some definition immediately leads to information, where an error will occur.
246
250
We were able to replace all our occurences of `.resolve(` and `.register(` using the current implementation.
247
251
248
-
249
252
## Contributors
250
-
The main contributors for this are [Daniel Dengler](https://github.com/ddengler), [David Kraus](https://github.com/davidkraus) and [Wolfgang Lutz](https://github.com/lutzifer).
253
+
The original idea for combining CodeGeneration and Swinject came from [Daniel Dengler](https://github.com/ddengler), [David Kraus](https://github.com/davidkraus) and [Wolfgang Lutz](https://github.com/lutzifer).
0 commit comments