Get Swift Package Version at Runtime

Hey,

Coming from nodeJS and its package.json, which always carries a version property, I was wondering whether it is possible to set a version number/string for a Swift Package, besides tagging in Git.

The reason for that is that I would like to use that version string in API calls to let my backend know which version of a Swift Package it is talking to.

Obviously what comes to mind is simply setting a constant for the version somewhere, but I was wondering if there is a better approach.

Kind regards,
Felix

1 Like

Usually I do this in the Xcode build settings for regular targets, or in the Package.swift for Swift Package targets.

There is no general purpose approach for this. I would quite like to see one though.

2 Likes