diff --git a/Documentation/Concurrency.md b/Documentation/Concurrency.md index 79ddf380b..dbf0cf4a2 100644 --- a/Documentation/Concurrency.md +++ b/Documentation/Concurrency.md @@ -137,7 +137,7 @@ try dbQueue.write { db in
Swift concurrency (async/await) -[**:fire: EXPERIMENTAL**](../README.md#what-are-experimental-features) GRDB support for Swift concurrency requires Xcode 13.2+. +[**:fire: EXPERIMENTAL**](../README.md#what-are-experimental-features) GRDB support for Swift concurrency requires Xcode 13.3.1+. ```swift let playerCount = try await dbQueue.read { db in diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 955e99725..0958e661d 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -160,7 +160,7 @@ public final class DatabasePool: DatabaseWriter { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) // @unchecked because of databaseSnapshotCount and readerPool extension DatabasePool: @unchecked Sendable { } #endif diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index 11afc3d48..d5ff1f34f 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -371,7 +371,7 @@ extension DatabaseReader { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) extension DatabaseReader { // MARK: - Asynchronous Database Access diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index e4c430af5..41e02913f 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -159,7 +159,7 @@ extension DatabaseValue: StatementBinding { extension DatabaseValue: GRDBSendable { } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) // @unchecked due to Foundation.Data not conforming to Sendable // TODO: Remove @unchecked when Foundation has been upgraded extension DatabaseValue.Storage: @unchecked Sendable { } diff --git a/GRDB/Core/DatabaseWriter.swift b/GRDB/Core/DatabaseWriter.swift index f0dab2dda..3ab24d3ea 100644 --- a/GRDB/Core/DatabaseWriter.swift +++ b/GRDB/Core/DatabaseWriter.swift @@ -380,7 +380,7 @@ extension DatabaseWriter { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) extension DatabaseWriter { // MARK: - Asynchronous Database Access diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index c17c183e6..4d340307e 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -2182,7 +2182,7 @@ struct ArrayRowImpl: RowImpl { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) // @unchecked because columns property is not inferred as Sendable // TODO: remove this @unchecked when compiler can handle tuples. extension ArrayRowImpl: @unchecked Sendable { } diff --git a/GRDB/Core/SerializedDatabase.swift b/GRDB/Core/SerializedDatabase.swift index 1b2686ad8..0b261340a 100644 --- a/GRDB/Core/SerializedDatabase.swift +++ b/GRDB/Core/SerializedDatabase.swift @@ -249,7 +249,7 @@ final class SerializedDatabase { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) // @unchecked because the wrapped `Database` itself is not Sendable. // It happens the job of SerializedDatabase is precisely to provide thread-safe // access to `Database`. diff --git a/GRDB/Utils/Utils.swift b/GRDB/Utils/Utils.swift index fdc904ea6..f42e0f2ce 100644 --- a/GRDB/Utils/Utils.swift +++ b/GRDB/Utils/Utils.swift @@ -32,7 +32,7 @@ public protocol _OptionalProtocol { /// :nodoc: extension Optional: _OptionalProtocol { } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) public typealias GRDBSendable = Swift.Sendable #else public typealias GRDBSendable = Any diff --git a/GRDB/ValueObservation/SharedValueObservation.swift b/GRDB/ValueObservation/SharedValueObservation.swift index 7e5877369..8ef622ba9 100644 --- a/GRDB/ValueObservation/SharedValueObservation.swift +++ b/GRDB/ValueObservation/SharedValueObservation.swift @@ -299,7 +299,7 @@ public final class SharedValueObservation { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) 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 730e8bafb..bdfb58e3b 100644 --- a/GRDB/ValueObservation/ValueObservation.swift +++ b/GRDB/ValueObservation/ValueObservation.swift @@ -252,7 +252,7 @@ extension ValueObservation: Refinable { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) extension ValueObservation { // MARK: - Asynchronous Observation /// The database observation, as an asynchronous sequence of diff --git a/README.md b/README.md index ab7f68e20..f53d9444f 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ GRDB ships with: - [WAL Mode Support](#database-pools): Extra performance for multi-threaded applications. - [Migrations]: Transform your database as your application evolves. - [Database Observation]: Observe database changes and transactions. -- [Swift Concurrency]: `try await` your database (Xcode 13.2+). +- [Swift Concurrency]: `try await` your database (Xcode 13.3.1+). - [Combine Support]: Access and observe the database with Combine publishers. - [RxSwift Support](http://github.com/RxSwiftCommunity/RxGRDB): Access and observe the database with RxSwift observables. - [Full-Text Search] diff --git a/Tests/GRDBCombineTests/Support.swift b/Tests/GRDBCombineTests/Support.swift index 17a6c3542..88e194c50 100644 --- a/Tests/GRDBCombineTests/Support.swift +++ b/Tests/GRDBCombineTests/Support.swift @@ -51,7 +51,7 @@ final class Test { } } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) final class AsyncTest { // Raise the repeatCount in order to help spotting flaky tests. diff --git a/Tests/GRDBTests/DatabaseReaderTests.swift b/Tests/GRDBTests/DatabaseReaderTests.swift index d7de647ed..d16284f8a 100644 --- a/Tests/GRDBTests/DatabaseReaderTests.swift +++ b/Tests/GRDBTests/DatabaseReaderTests.swift @@ -30,7 +30,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(setup(makeDatabasePool()).makeSnapshot()) } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_ReadCanRead() async throws { func setup(_ dbWriter: T) throws -> T { @@ -68,7 +68,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(makeDatabasePool().makeSnapshot()) } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_ReadPreventsDatabaseModification() async throws { func test(_ dbReader: DatabaseReader) async throws { @@ -107,7 +107,7 @@ class DatabaseReaderTests : GRDBTestCase { try test(setup(makeDatabasePool()).makeSnapshot()) } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_UnsafeReadCanRead() async throws { func setup(_ dbWriter: T) throws -> T { diff --git a/Tests/GRDBTests/DatabaseWriterTests.swift b/Tests/GRDBTests/DatabaseWriterTests.swift index 61ae91f99..5a7b4c433 100644 --- a/Tests/GRDBTests/DatabaseWriterTests.swift +++ b/Tests/GRDBTests/DatabaseWriterTests.swift @@ -266,7 +266,7 @@ class DatabaseWriterTests : GRDBTestCase { try DatabaseQueue().backup(to: dbQueue) } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_write() async throws { func setup(_ dbWriter: T) throws -> T { @@ -288,7 +288,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_writeWithoutTransaction() async throws { func setup(_ dbWriter: T) throws -> T { @@ -313,7 +313,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_barrierWriteWithoutTransaction() async throws { func setup(_ dbWriter: T) throws -> T { @@ -338,7 +338,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_erase() async throws { func setup(_ dbWriter: T) throws -> T { @@ -358,7 +358,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait_vacuum() async throws { func setup(_ dbWriter: T) throws -> T { @@ -376,7 +376,7 @@ class DatabaseWriterTests : GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.16, iOS 14, tvOS 14, watchOS 7, *) // async + vacuum into func testAsyncAwait_vacuumInto() async throws { // Prevent SQLCipher failures diff --git a/Tests/GRDBTests/GRDBTestCase.swift b/Tests/GRDBTests/GRDBTestCase.swift index f34adc0c7..6c0d5b2e4 100644 --- a/Tests/GRDBTests/GRDBTestCase.swift +++ b/Tests/GRDBTests/GRDBTestCase.swift @@ -259,7 +259,7 @@ public struct AnyValueReducer: ValueReducer { } } -#if swift(>=5.5) && canImport(_Concurrency) +#if swift(>=5.6) && canImport(_Concurrency) // Assume this is correct :-/ extension XCTestExpectation: @unchecked Sendable { } #endif diff --git a/Tests/GRDBTests/SharedValueObservationTests.swift b/Tests/GRDBTests/SharedValueObservationTests.swift index c6a915d83..45610e39e 100644 --- a/Tests/GRDBTests/SharedValueObservationTests.swift +++ b/Tests/GRDBTests/SharedValueObservationTests.swift @@ -621,7 +621,7 @@ class SharedValueObservationTests: GRDBTestCase { } #endif -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) func testAsyncAwait() async throws { let dbQueue = try makeDatabaseQueue() diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift index 6b4aea8c4..0f6566e6b 100644 --- a/Tests/GRDBTests/ValueObservationTests.swift +++ b/Tests/GRDBTests/ValueObservationTests.swift @@ -694,7 +694,7 @@ class ValueObservationTests: GRDBTestCase { try test(makeDatabasePool()) } -#if compiler(>=5.5.2) && canImport(_Concurrency) +#if compiler(>=5.6) && canImport(_Concurrency) // MARK: - Async Await @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)