Skip to content

Commit

Permalink
Fix incorrect or confusing documentation about Swift versions
Browse files Browse the repository at this point in the history
Rewrote Markdown to properly specify Swift 5.7 instead of 5.5,
and to clarify other information related to Swift versions.

Resolve apple#677

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
  • Loading branch information
rgoldberg committed Oct 31, 2024
1 parent 72bf212 commit e7369ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ let package = Package(

### Supported Versions

The most recent versions of swift-argument-parser support Swift 5.5 and newer. The minimum Swift version supported by swift-argument-parser releases are detailed below:
The minimum Swift version supported by swift-argument-parser releases are detailed below:

swift-argument-parser | Minimum Swift Version
----------------------|----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and then include `"ArgumentParser"` as a dependency for our executable target.
Our "Package.swift" file ends up looking like this:

```swift
// swift-tools-version:5.5
// swift-tools-version:5.7
import PackageDescription

let package = Package(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@ struct CountLines: AsyncParsableCommand {
### Usage in Swift 5.5

In Swift 5.5, you need to declare a separate, standalone type as your asynchronous `@main` entry point. Instead of designating your root command as `@main`, as described above, use the code snippet below, replacing the placeholder with the name of your own root command. Otherwise, follow the steps above to use `async`/`await` code within your commands' `run()` methods.
Swift 5.5 is supported by the obsolete versions 1.1.x & 1.2.x versions of Swift Argument Parser.

In Swift 5.5, an asynchronous `@main` entry point must be declared as a separate standalone type.

Your root command cannot be designated as `@main`, unlike as described above.

Instead, use the code snippet below, replacing the `<#RootCommand#>` placeholder with the name of your own root command.

```swift
@main struct AsyncMain: AsyncMainProtocol {
typealias Command = <#RootCommand#>
}
```

Continue to follow the other steps above to use `async`/`await` code within your commands' `run()` methods.

## Topics

### Implementing a Command's Behavior
Expand All @@ -47,4 +55,3 @@ In Swift 5.5, you need to declare a separate, standalone type as your asynchrono

- ``main()``
- ``AsyncMainProtocol``

0 comments on commit e7369ac

Please sign in to comment.