Generate Swift sources in SPM

(Gábor Sebestyén) #1


I wonder if I can make it with SPM easily (out of the box or extended with custom code). I want to generate Swift sources from templates in a web app project. There would be a special target that encapsulates this step. Template files are compiled with a 3rd party tool into a temporary folder probably under .build folder and they will take part of the whole build process.

In my case template files are HTML fragments and 3rd compiler turns them to renderer functions (like JSP -> Java servlet).

Before I dig deep into SPM source I ask the community if it is feasible or forget SPM and do the pre-compilation step via scripting.


1 Like
(Jeremy David Giesbrecht) #2

At the moment, the autogeneration step cannot be directly integrated. You have to trigger the generation manually before executing swift build. That means that if you expect client packages to depend on yours, you will have to check the generated files into your tagged releases, so that the sources are available for clients to check out directly.

The feature you ask will most likely be implemented eventually, it just has not happened yet. See here for the design discussion.

1 Like
(Gábor Sebestyén) #3

I really hope it will be eventually implemented soon. I already wrote my scripted solution but the downside is managing generated sources in VCS. They have to be done manually which is fine as long as only existing files changed.