Demo of using Swift Argument Parser and await/async
- Commit be39f86: I created a new package with
swift package init --type executable --name RepeatCommandLineTool
. This Swift package can be build and executed withswift run
- Commit 295881c: I added Swift Argument Parser (
1.0.0
) and Apple'sRepeat
example (sync processing). Build and run withswift run repeat --count 5 HelloWorld
- Commit 929075b: I used
@main
attribute and therefore had to renamemain.swift
file to avoid the error'main' attribute cannot be used in a module that contains top-level code
- Commit 3909324: I added new code artifacts to convert the example to use async/await
- Commit 6be7396: I adopted Swift ArgumentParser
1.1.0
which has native support for async/await.
If you encounter the error
dyld: Library not loaded: @rpath/libswift_Concurrency.dylib
when running the command-line tool from within Xcode on a macOS version < 12.0 then you can enable the commented code inPackage.swift
(introduced with commit 26c67af)