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
In many circumstances, you might want an executable to know about the package version(s) that was used, so the program can give according infos to the user of the program e.g. in case of an error. This should be possible also for programs being distributed as one single executable file. Because this seems to a common issue, an easy to use solution should exist.
… there should be e.g. a macro #packageVersions making a (literal) map with the versions as part of the standard library. …
Alternatives considered
You cannot do this with your own macro that reads the Package.resolved file, because reading files is prohibited for a macro because of security reasons. Same issue when calling Git.
Take a look at what Swift Testing does: we create a C/C++ target, define C macros in that target that correspond to the gitInformation fields we care about, then bubble those macros up to Swift.
But this is complicated.
Additional information
No response
The text was updated successfully, but these errors were encountered:
Motivation
In many circumstances, you might want an executable to know about the package version(s) that was used, so the program can give according infos to the user of the program e.g. in case of an error. This should be possible also for programs being distributed as one single executable file. Because this seems to a common issue, an easy to use solution should exist.
Proposed solution
From https://forums.swift.org/t/inserting-gitinformation-into-source-code/77128:
Alternatives considered
You cannot do this with your own macro that reads the Package.resolved file, because reading files is prohibited for a macro because of security reasons. Same issue when calling Git.
From https://forums.swift.org/t/inserting-gitinformation-into-source-code/77128:
But this is complicated.
Additional information
No response
The text was updated successfully, but these errors were encountered: