Hi folks,
In the documentation for PackageDescription.Target
, both of the two static methods .executableTarget(...)
are marked as deprecated. There is no suggestion in the documentation as to what alternative people should use, if not those static methods.
Most examples in the wild I've found currently use .executableTarget()
. The swift package init --type tool
command will generate a Package.swift
file which uses .executableTarget()
(on Apple Swift version 6.0.2).
The only example I've found which has a possible alternative is the first example within the Products section of this doc. In this example, the more generic .target()
is used, while a corresponding product is also specified using the Product.executable()
static method. Is this the recommended practice? I'm inclined to believe its not - since when I use this approach and build I see a warning similar to:
warning: 'my-package': 'SomeTarget' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'
This seems to directly state that I should be using the deprecated .executableTarget(...)
. Is that only because I happened to use a main.swift
file? Is there some alternative to naming that would eliminate this warning, without having to introduce the deprecated .executableTarget(...)
?
Is there any more nuance available regarding when and why one approach or another should be chosen?
Thanks