I put down some thoughts around SPM plugins here and got directed to this thread.
I'd be very interested in code-generation and this seems like a workable approach. A couple of things to consider-
In the example MyPackage -> Package.swift
file provided, the SwiftyCURL
dependency is probably a requirement of the generated code rather than the static code in the package itself. In such a situation, this dependency is not really modelled correctly-
-
MyPackage
is making an assumption that the generated code requiresSwiftyCURL
as a dependency. This requires some kind of knowledge of the code that is going to be generated - probably through documentation of the generator which is not a strong contract. -
MyPackage
is making an assumption that version 1.0.0 ofSwiftyCURL
is acceptable for the generated code. Conversely, the generator has no way of safely using non-breaking API additions introduced in minor versions of its runtime dependencies. -
MyPackage
is making an assumption that the generated code doesn't use any other dependencies thanSwiftyCURL
. Conversely, the code generator has no way of adding dependencies even if those additions are considered non-breaking.
This proposal provides a mechanism for generating the actual code but it leaves dependency management to be handled by the consuming package rather by the generator package which seems more appropriate.