<div dir="ltr">Hi,<div><br></div><div>I&#39;ve recently open sourced a dependency injection framework for Swift called Cleanse. <a href="https://github.com/square/cleanse">https://github.com/square/cleanse</a></div><div><br></div><div>It does a couple things I&#39;d consider novel with the type system to make wiring up functions easy without having to use reflection or other runtime or compile-time hacks (I tried elaborating on it in this part of the README here <a href="https://github.com/square/Cleanse#dependency-requesting-terminating-methods">https://github.com/square/Cleanse#dependency-requesting-terminating-methods</a>)</div><div><br></div><div>Anyways, I&#39;m looking for feedback on the design and use of this library, and maybe strike up a discussion on language features that may make writing a library such as this be able to be &quot;cleaner&quot; in the future. Couple things that come to mind are custom annotations for qualifying types (instead of what we call &quot;type tags&quot;), variadic generic arguments (which we work around by code generating the various arities), or even a plugin architecture to achieve things similar to what can be done with Java annotation processors.</div><div><br></div><div>I&#39;d also be interested in feedback on some more of the implementation details. e.g. is using this to key objects by type a good thing or a terrible thing? <a href="https://github.com/square/Cleanse/blob/master/Cleanse/TypeKeyProtocol.swift">https://github.com/square/Cleanse/blob/master/Cleanse/TypeKeyProtocol.swift</a></div><div><br></div><div>Since Swift generics don&#39;t seem to be completely understood by the general population, was hoping I could get some concrete feedback here. Even would be stoked with a response to the tune of &quot;You don&#39;t need DI in Swift for reasons X, Y, and Z.&quot;</div><div><br></div><div>Thanks!</div><div>Mike Lewis</div></div>