Swift-Async-Await-Experiments
Swift-Async-Await-Experiments copied to clipboard
Experiments with Swift's new async/await feature (SE 0296)
Swift async/await Experiments
Experiments with Swift's new async/await feature (SE 0296)
Join the discussion
·
Report Bug
·
Request Feature
About The Project
Experiments with Swift's new async/await feature (SE 0296)
Here's an article that shows you how to use this feature.
Requirements
Previous versions of the code in this repository made use of the experimental Swift compiler toolchain. Since WWDC 2021, support for async/await is now available in the default compiler toolchain.
- Xcode 13 or later
- ~~Swift Compiler Toolchain (Jan 04, 2021 or later)~~
Breaking changes
As this is still in development, there will be changes. I updated the code to reflect those changes, and wouldn't be surprised to see further breaking changes before a final release is cut. If you run into any issues, feel free to open an issue on this repo (or even better - send a PR if you've got time time to build a solution).
2022-11-05
- Updated the code to use
Task { }
instead ofasync { }
2021-08-06 (WWDC 21)
- Xcode 13 now contains Swift 5.5, we no longer need to download the experimental compiler toolchain
-
According to the Swift team, the correct way to launch an async task from with in SwiftUI is
async { }
(in beta 1) orTask { }
(after beta 1).
2021-05-25
The Swift Development team has been making a couple of breaking changes (after all, this is still pre-release software):
-
@asyncHandler
has been removed from the language (see PR #37415). According to this discussion, we can wrap asynchronous code in a call todetach { }
as an alternative. As of yet, it is unclear what if there will be a replacement for@asyncHandler
. - Since Swift can now be shipped with the OS, all new features in the Swift standard library will need to have an availability annotation. To be able to mark new APIs as available for unreleased versions of future versions of the OS, a special case of
9999
has been introduced. This also means that all code using those new APIs will need to use availability flags as well. For details, see this discussion on the Swift forums.
License
Distributed under the Apache 2 License. See LICENSE
for more information.