From c755dc70ef21877e40cb8d03125c728d64363a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 30 Oct 2021 20:09:39 +0200 Subject: [PATCH] Restrict async/await to Xcode 13.1+ --- Documentation/DemoApps/GRDBAsyncDemo/README.md | 2 ++ Documentation/DemoApps/README.md | 5 +++-- GRDB/Core/DatabaseReader.swift | 2 +- GRDB/Core/DatabaseWriter.swift | 2 +- GRDB/Migration/DatabaseMigrator.swift | 4 ++-- GRDB/ValueObservation/SharedValueObservation.swift | 2 +- GRDB/ValueObservation/ValueObservation.swift | 2 +- Tests/GRDBCombineTests/Support.swift | 2 +- Tests/GRDBTests/DatabaseMigratorTests.swift | 4 ++-- Tests/GRDBTests/DatabaseReaderTests.swift | 6 +++--- Tests/GRDBTests/DatabaseWriterTests.swift | 12 ++++++------ Tests/GRDBTests/SharedValueObservationTests.swift | 2 +- Tests/GRDBTests/ValueObservationTests.swift | 2 +- 13 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Documentation/DemoApps/GRDBAsyncDemo/README.md b/Documentation/DemoApps/GRDBAsyncDemo/README.md index 2fe3a2232..89e307f12 100644 --- a/Documentation/DemoApps/GRDBAsyncDemo/README.md +++ b/Documentation/DemoApps/GRDBAsyncDemo/README.md @@ -5,6 +5,8 @@ Async/Await + SwiftUI Demo Application **This demo application is an Async/Await + SwiftUI application.** For a demo application that uses UIKit, see [GRDBDemoiOS](../GRDBDemoiOS/README.md), and for Combine + SwiftUI, see [GRDBCombineDemo](../GRDBCombineDemo/README.md). +**Requirements**: iOS 15.0+ / Xcode 13.1+ + > :point_up: **Note**: This demo app is not a project template. Do not copy it as a starting point for your application. Instead, create a new project, choose a GRDB [installation method](../../../README.md#installation), and use the demo as an inspiration. The topics covered in this demo are: diff --git a/Documentation/DemoApps/README.md b/Documentation/DemoApps/README.md index 6316ac039..d940698aa 100644 --- a/Documentation/DemoApps/README.md +++ b/Documentation/DemoApps/README.md @@ -1,5 +1,6 @@ Demo Applications ================= -- [UIKit Demo Application](GRDBDemoiOS/README.md): a storyboard-based UIKit application. -- [Combine + SwiftUI Demo Application](GRDBCombineDemo/README.md): a Combine + SwiftUI application. +- [GRDBDemoiOS](GRDBDemoiOS/README.md): a storyboard-based UIKit application. +- [GRDBCombineDemo](GRDBCombineDemo/README.md): a Combine + SwiftUI application. +- [GRDBAsyncDemo](GRDBAsyncDemo/README.md): a Async/Await + SwiftUI application. diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index e97de42f6..f80f19e3f 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -307,7 +307,7 @@ extension DatabaseReader { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) extension DatabaseReader { // MARK: - Asynchronous Database Access diff --git a/GRDB/Core/DatabaseWriter.swift b/GRDB/Core/DatabaseWriter.swift index dc1724b94..daa8bb32f 100644 --- a/GRDB/Core/DatabaseWriter.swift +++ b/GRDB/Core/DatabaseWriter.swift @@ -415,7 +415,7 @@ extension DatabaseWriter { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) extension DatabaseWriter { // MARK: - Asynchronous Database Access diff --git a/GRDB/Migration/DatabaseMigrator.swift b/GRDB/Migration/DatabaseMigrator.swift index df713fdf5..d5299915f 100644 --- a/GRDB/Migration/DatabaseMigrator.swift +++ b/GRDB/Migration/DatabaseMigrator.swift @@ -115,7 +115,7 @@ public struct DatabaseMigrator { try migrate(writer, upTo: lastMigration.identifier) } - #if swift(>=5.5) && canImport(_Concurrency) + #if compiler(>=5.5.1) /// Iterate migrations in the same order as they were registered. If a /// migration has not yet been applied, its block is executed in /// a transaction. @@ -149,7 +149,7 @@ public struct DatabaseMigrator { } } - #if swift(>=5.5) && canImport(_Concurrency) + #if compiler(>=5.5.1) /// Iterate migrations in the same order as they were registered, up to the /// provided target. If a migration has not yet been applied, its block is /// executed in a transaction. diff --git a/GRDB/ValueObservation/SharedValueObservation.swift b/GRDB/ValueObservation/SharedValueObservation.swift index 52be41dbd..ecfa80f92 100644 --- a/GRDB/ValueObservation/SharedValueObservation.swift +++ b/GRDB/ValueObservation/SharedValueObservation.swift @@ -295,7 +295,7 @@ public final class SharedValueObservation { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) extension SharedValueObservation { // MARK: - Asynchronous Observation /// The database observation, as an asynchronous sequence of diff --git a/GRDB/ValueObservation/ValueObservation.swift b/GRDB/ValueObservation/ValueObservation.swift index 3770d0203..83b4098ac 100644 --- a/GRDB/ValueObservation/ValueObservation.swift +++ b/GRDB/ValueObservation/ValueObservation.swift @@ -219,7 +219,7 @@ extension ValueObservation: Refinable { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) extension ValueObservation { // MARK: - Asynchronous Observation /// The database observation, as an asynchronous sequence of diff --git a/Tests/GRDBCombineTests/Support.swift b/Tests/GRDBCombineTests/Support.swift index 6b78efc6c..29404c9c1 100644 --- a/Tests/GRDBCombineTests/Support.swift +++ b/Tests/GRDBCombineTests/Support.swift @@ -51,7 +51,7 @@ final class Test { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) final class AsyncTest { // Raise the repeatCount in order to help spotting flaky tests. diff --git a/Tests/GRDBTests/DatabaseMigratorTests.swift b/Tests/GRDBTests/DatabaseMigratorTests.swift index 954346ad4..30c77aa9d 100644 --- a/Tests/GRDBTests/DatabaseMigratorTests.swift +++ b/Tests/GRDBTests/DatabaseMigratorTests.swift @@ -98,7 +98,7 @@ class DatabaseMigratorTests : GRDBTestCase { .runAtTemporaryDatabasePath { try DatabasePool(path: $0) } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_NonEmptyMigratorSync() async throws { func test(writer: DatabaseWriter) async throws { @@ -423,7 +423,7 @@ class DatabaseMigratorTests : GRDBTestCase { .runAtTemporaryDatabasePath { try DatabasePool(path: $0) } } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_MigrateUpTo() async throws { func test(writer: DatabaseWriter) async throws { diff --git a/Tests/GRDBTests/DatabaseReaderTests.swift b/Tests/GRDBTests/DatabaseReaderTests.swift index 5ec1fc2b2..34b6fc249 100644 --- a/Tests/GRDBTests/DatabaseReaderTests.swift +++ b/Tests/GRDBTests/DatabaseReaderTests.swift @@ -30,7 +30,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(setup(makeDatabasePool()).makeSnapshot()) } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_ReadCanRead() async throws { func setup(_ dbWriter: T) throws -> T { @@ -68,7 +68,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(makeDatabasePool().makeSnapshot()) } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_ReadPreventsDatabaseModification() async throws { func test(_ dbReader: DatabaseReader) async throws { @@ -107,7 +107,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(setup(makeDatabasePool()).makeSnapshot()) } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_UnsafeReadCanRead() async throws { func setup(_ dbWriter: T) throws -> T { diff --git a/Tests/GRDBTests/DatabaseWriterTests.swift b/Tests/GRDBTests/DatabaseWriterTests.swift index 56bbdaab3..532d39bb8 100644 --- a/Tests/GRDBTests/DatabaseWriterTests.swift +++ b/Tests/GRDBTests/DatabaseWriterTests.swift @@ -266,7 +266,7 @@ class DatabaseWriterTests : GRDBTestCase { try DatabaseQueue().backup(to: dbQueue) } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_write() async throws { func setup(_ dbWriter: T) throws -> T { @@ -288,7 +288,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_writeWithoutTransaction() async throws { func setup(_ dbWriter: T) throws -> T { @@ -313,7 +313,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_barrierWriteWithoutTransaction() async throws { func setup(_ dbWriter: T) throws -> T { @@ -338,7 +338,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_erase() async throws { func setup(_ dbWriter: T) throws -> T { @@ -358,7 +358,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_vacuum() async throws { func setup(_ dbWriter: T) throws -> T { @@ -376,7 +376,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait_vacuumInto() async throws { func setup(_ dbWriter: T) throws -> T { diff --git a/Tests/GRDBTests/SharedValueObservationTests.swift b/Tests/GRDBTests/SharedValueObservationTests.swift index 31a4bc987..74963e110 100644 --- a/Tests/GRDBTests/SharedValueObservationTests.swift +++ b/Tests/GRDBTests/SharedValueObservationTests.swift @@ -602,7 +602,7 @@ class SharedValueObservationTests: GRDBTestCase { } #endif -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testAsyncAwait() async throws { let dbQueue = try makeDatabaseQueue() diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift index 7d11a2b65..cfee84138 100644 --- a/Tests/GRDBTests/ValueObservationTests.swift +++ b/Tests/GRDBTests/ValueObservationTests.swift @@ -519,7 +519,7 @@ class ValueObservationTests: GRDBTestCase { try test(makeDatabasePool()) } -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.1) // MARK: - Async Await @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)