I barely understand what is going on here, so maybe this correct behavior, but it feels pretty terrible.
I’m working on a little command line tool that doesn’t generally require macOS. Using ArgumentParser. It does do a lot of networking calls, so it uses the AsyncParsableCommand
variant, an example of which looks like this:
@main
@available(macOS 12, *)
struct CountLines: AsyncParsableCommand {
static func main() async throws {
}
}
This didn’t work for me, but I didn’t include the @available(macOS 12, *)
line. I’m told that Swift was incorrectly choosing the synchronous run()
variant inherited from ParsableCommand
. Somehow, with the addition of @available(macOS 12, *)
, it chooses the async variant I provide.
This feels pretty obscure to me, and I also dislike it because do I now have to add availability declarations for every conceivable platform? I can’t even find a list of defined platform strings for @available
.