Useful extensions built upon Swift Concurrency

What's New


  • Update to Swift 5.9
  • Add XCTestCase.serialized() and XCTestCase.yield() for easy and reliable async tests
  • Add Publisher.asyncValues to create an AsyncStream that only holds onto the most recent value


The AsyncExtensions target is a growing collection of useful functions and classes that take advantage of Swift's new Concurrency features.

The AsyncExtensions package also inlcudes the AsyncTestExtensions target, which contains async-friendly wrappers around XCTest assertions.

AsyncExtensions includes

  • AsyncInputStream: A convenient wrapper around InputStream allowing for simple, type-safe access to stream data.
  • AsyncOutputStream: A convenient wrapper around OutputStream allowing for simple, type-safe streaming of data.
  • Publisher.allValues: Creates an AsyncStream from a Combine Publisher. It buffers all of the publisher's output, ensuring the AsyncStream will produce everything the publisher publishes.
  • Future: A thread-safe implemention of a future that is useful when briding traditional Swift code with code employing Swift Concurrency.
  • Sequence.asyncMap() and Sequence.concurrentMap(): Extensions allowing for applying async transformations to Sequence.
  • TaskStore: A thread-safe store for Task, which can help when migrating from Combine publishers to Swift Concurrency.
  • TimeoutError: A simple error intending to represent a timeout. Modelled after CancellationError.

AsyncTestExtensions includes

  • AssertEqual()
  • AssertEqualEventually()
  • AssertTrue()
  • AssertTrueEventually()
  • AssertFalse()
  • AssertNil()
  • AssertNotNil()
  • AssertThrowsError()
  • AssertNoThrow()
  • XCTestCase.task()
  • XCTestCase.serialized()
  • XCTestCase.yield()


To use AsyncExtensions, add a dependency to your Package.swift file:

let package = Package(
  dependencies: [
      url: "",
      from: "4.3.0"

To use AsyncTestExtensions in a test target, add it as a dependency:

  name: "MyTests",
  dependencies: [
    .product(name: "AsyncTestExtensions", package: "async-extensions")


The license for AsyncExtensions is the standard MIT licence. You can find it in the LICENSE file.

SequenceExtensions were heavily inspired by CollectionConcurrencyKit by John Sundell at

The main serial executor XCTestCase extensions were taken from swift-concurrency-extras by Point-Free at


  • Swift Tools 5.9.0
View More Packages from this Author


Last updated: Sat Mar 16 2024 20:36:55 GMT-0900 (Hawaii-Aleutian Daylight Time)