How to use @main annotation: I figure out how by deleting `main.swift`, did I do it right?

In Xcode, I created a macOS Command Line Tool project which include a main.swift file. I want to use @​main annotation on ParsableCommand. When @​main is added to a ParsableCommand, I get error:

'main' attribute cannot be used in a module that contains top-level code

When I delete the main.swift file, it fixed the problem and work. Is this the correct thing to do?

Is there some documentation explaining how to use @​main for ArgumentParser app?

Correct! I've opened an issue to track adding documentation for this.

2 Likes