From 0b6dbe134d275214e3f7366b4e65b83ce24cc058 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Tue, 28 Nov 2023 22:34:33 -0800 Subject: [PATCH] Adopt Swift 5.9 (#22) --- .github/workflows/ci.yml | 44 +++---------------------- AsyncQueue.podspec | 4 +-- Gemfile | 2 +- Gemfile.lock | 40 ++++++++++++++-------- Package.swift | 2 +- README.md | 8 ++--- Sources/AsyncQueue/ActorQueue.swift | 9 ++--- Sources/AsyncQueue/FIFOQueue.swift | 9 ++--- Sources/AsyncQueue/MainActorQueue.swift | 9 ++--- 9 files changed, 44 insertions(+), 83 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b9cf1f..6d36878 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,45 +16,9 @@ jobs: - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer - name: Lint Podspec - run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.8 - spm-14: - name: Build Xcode 14 - runs-on: macos-13 - strategy: - matrix: - platforms: [ - 'iOS_16,watchOS_9', - 'macOS_13,tvOS_16', - ] - fail-fast: false - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - name: Bundle Install - run: bundle install - - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer - - name: Build and Test Framework - run: Scripts/build.swift ${{ matrix.platforms }} - - name: Prepare Coverage Reports - run: ./Scripts/prepare-coverage-reports.sh - - name: Upload Coverage Reports - if: success() - uses: codecov/codecov-action@v3 - spm-14-swift: - name: Swift Build Xcode 14 - runs-on: macos-13 - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - name: Bundle Install - run: bundle install - - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer - - name: Build and Test Framework - run: xcrun swift test -c release -Xswiftc -enable-testing + run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.9 spm-15: name: Build Xcode 15 runs-on: macos-13 @@ -71,7 +35,7 @@ jobs: - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_15.0.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer - name: Build and Test Framework run: Scripts/build.swift ${{ matrix.platforms }} - name: Prepare Coverage Reports @@ -88,6 +52,6 @@ jobs: - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_15.0.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer - name: Build and Test Framework run: xcrun swift test -c release -Xswiftc -enable-testing diff --git a/AsyncQueue.podspec b/AsyncQueue.podspec index ee42600..9701b42 100644 --- a/AsyncQueue.podspec +++ b/AsyncQueue.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = 'AsyncQueue' - s.version = '0.4.0' + s.version = '0.5.0' s.license = 'MIT' s.summary = 'A queue that enables ordered sending of events from synchronous to asynchronous code.' s.homepage = 'https://github.com/dfed/swift-async-queue' s.authors = 'Dan Federman' s.source = { :git => 'https://github.com/dfed/swift-async-queue.git', :tag => s.version } - s.swift_version = '5.8' + s.swift_version = '5.9' s.source_files = 'Sources/**/*.{swift}' s.ios.deployment_target = '13.0' s.tvos.deployment_target = '13.0' diff --git a/Gemfile b/Gemfile index 99cf8e7..186a1ef 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,4 @@ ruby '3.0.6' source 'https://rubygems.org' -gem 'cocoapods', '~> 1.12.0' +gem 'cocoapods', '~> 1.14.0' diff --git a/Gemfile.lock b/Gemfile.lock index bad3078..1d3b2e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,24 +3,31 @@ GEM specs: CFPropertyList (3.0.6) rexml - activesupport (7.0.7.2) + activesupport (7.1.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - addressable (2.8.3) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) + base64 (0.2.0) + bigdecimal (3.1.4) claide (1.1.0) - cocoapods (1.12.0) + cocoapods (1.14.3) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.12.0) + cocoapods-core (= 1.14.3) cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.6.0, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-trunk (>= 1.6.0, < 2.0) @@ -32,8 +39,8 @@ GEM molinillo (~> 0.8.0) nap (~> 1.0) ruby-macho (>= 2.3.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.12.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.14.3) activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) @@ -44,7 +51,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.3) + cocoapods-downloader (2.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -54,10 +61,13 @@ GEM cocoapods-try (1.2.0) colored2 (3.1.2) concurrent-ruby (1.2.2) + connection_pool (2.4.1) + drb (2.2.0) + ruby2_keywords escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) - ffi (1.15.5) + ffi (1.16.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) @@ -65,19 +75,21 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.6.3) - minitest (5.19.0) + minitest (5.20.0) molinillo (0.8.0) + mutex_m (0.2.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) public_suffix (4.0.7) - rexml (3.2.5) + rexml (3.2.6) ruby-macho (2.5.1) - typhoeus (1.4.0) + ruby2_keywords (0.0.5) + typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.22.0) + xcodeproj (1.23.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) @@ -89,7 +101,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.12.0) + cocoapods (~> 1.14.0) RUBY VERSION ruby 3.0.6p216 diff --git a/Package.swift b/Package.swift index 7adff30..b4af598 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8 +// swift-tools-version: 5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/README.md b/README.md index 612ea57..4a5a892 100644 --- a/README.md +++ b/README.md @@ -168,12 +168,12 @@ func testMainActorQueueOrdering() async { ## Requirements -* Xcode 14.3 or later. +* Xcode 15.0 or later. * iOS 13 or later. * tvOS 13 or later. * watchOS 6 or later. * macOS 10.15 or later. -* Swift 5.8 or later. +* Swift 5.9 or later. ## Installation @@ -183,7 +183,7 @@ To install swift-async-queue in your iOS project with [Swift Package Manager](ht ```swift dependencies: [ - .package(url: "https://github.com/dfed/swift-async-queue", from: "0.4.0"), + .package(url: "https://github.com/dfed/swift-async-queue", from: "0.5.0"), ] ``` @@ -193,7 +193,7 @@ To install swift-async-queue in your iOS project with [CocoaPods](http://cocoapo ``` platform :ios, '13.0' -pod 'AsyncQueue', '~> 0.4.0' +pod 'AsyncQueue', '~> 0.5.0' ``` ## Contributing diff --git a/Sources/AsyncQueue/ActorQueue.swift b/Sources/AsyncQueue/ActorQueue.swift index 80f07f2..ba2655f 100644 --- a/Sources/AsyncQueue/ActorQueue.swift +++ b/Sources/AsyncQueue/ActorQueue.swift @@ -57,13 +57,8 @@ public final class ActorQueue: @unchecked Sendable { /// Instantiates an actor queue. public init() { - var capturedTaskStreamContinuation: AsyncStream.Continuation? = nil - let taskStream = AsyncStream { continuation in - capturedTaskStreamContinuation = continuation - } - // Continuation will be captured during stream creation, so it is safe to force unwrap here. - // If this force-unwrap fails, something is fundamentally broken in the Swift runtime. - taskStreamContinuation = capturedTaskStreamContinuation! + let (taskStream, taskStreamContinuation) = AsyncStream.makeStream() + self.taskStreamContinuation = taskStreamContinuation Task.detached { for await actorTask in taskStream { diff --git a/Sources/AsyncQueue/FIFOQueue.swift b/Sources/AsyncQueue/FIFOQueue.swift index 384e53f..cc6f9ba 100644 --- a/Sources/AsyncQueue/FIFOQueue.swift +++ b/Sources/AsyncQueue/FIFOQueue.swift @@ -30,13 +30,8 @@ public final class FIFOQueue: Sendable { /// Instantiates a FIFO queue. /// - Parameter priority: The baseline priority of the tasks added to the asynchronous queue. public init(priority: TaskPriority? = nil) { - var capturedTaskStreamContinuation: AsyncStream<@Sendable () async -> Void>.Continuation? = nil - let taskStream = AsyncStream<@Sendable () async -> Void> { continuation in - capturedTaskStreamContinuation = continuation - } - // Continuation will be captured during stream creation, so it is safe to force unwrap here. - // If this force-unwrap fails, something is fundamentally broken in the Swift runtime. - taskStreamContinuation = capturedTaskStreamContinuation! + let (taskStream, taskStreamContinuation) = AsyncStream<@Sendable () async -> Void>.makeStream() + self.taskStreamContinuation = taskStreamContinuation Task.detached(priority: priority) { for await task in taskStream { diff --git a/Sources/AsyncQueue/MainActorQueue.swift b/Sources/AsyncQueue/MainActorQueue.swift index 3dde0b7..8aa43d7 100644 --- a/Sources/AsyncQueue/MainActorQueue.swift +++ b/Sources/AsyncQueue/MainActorQueue.swift @@ -31,13 +31,8 @@ public final class MainActorQueue: Sendable { /// Instantiates a main actor queue. init() { - var capturedTaskStreamContinuation: AsyncStream<@Sendable @MainActor () async -> Void>.Continuation? = nil - let taskStream = AsyncStream<@Sendable @MainActor () async -> Void> { continuation in - capturedTaskStreamContinuation = continuation - } - // Continuation will be captured during stream creation, so it is safe to force unwrap here. - // If this force-unwrap fails, something is fundamentally broken in the Swift runtime. - taskStreamContinuation = capturedTaskStreamContinuation! + let (taskStream, taskStreamContinuation) = AsyncStream<@Sendable @MainActor () async -> Void>.makeStream() + self.taskStreamContinuation = taskStreamContinuation Task.detached { @MainActor in for await task in taskStream {