Is it possible to build a command with an asynchronous subcommand on macOS 11?

Am I correct if I say it is currently impossible to build a root async command that has subcommands with macOS 11?

My root command needs to be asynchronous because one of the subcommands is asynchronous. When I tried to compile my project — that was building just fine with macOS 12 — on an older laptop running macOS 11, I got the following error and couldn't find any workaround:

Foo is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void.

And I ended up writing something like:

    static func availableSubcommands() -> [ParsableCommand.Type] {
        var subcommands: [ParsableCommand.Type] = [ /** ... all my `ParsableCommand` subcommands */ ]
        if #available(macOS 12.0, *) {
            subcommands.append(/** ... my `AsyncParsableCommand` subcommand */)
        }
        return subcommands
    }
1 Like