I would like to use the package version (Git tag and/or commit hash) in the source code for automated version information within the executables, also checking the Git status.
I implemented a function that calls Git (git rev-parse HEAD
, git tag --contains ...
, checking changes via git status -z
) to get the according information, but in order for this to work for the executable this should be executed during compile time i.e. a (freestanding) macro should be used.
Unfortunately, during macros expansion calling an external program does not seem to be allowed (error: Failed to receive result from plugin
), and I also think that such a macro #packageVersion
could be a nice feature to be added "side by side" to #function
or #filePath
.
I also tried to include the "swift-package-manager“ package but this failed.
Maybe someone has an idea (or some code?) how to get the package version (or even as an additional feature all resolved package versions) into the source code, and is it true that calling an external program during macro expansion does not work?
6 posts - 4 participants