diff --git a/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/project.pbxproj b/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/project.pbxproj index 47782e062..6edc31973 100644 --- a/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/project.pbxproj +++ b/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/project.pbxproj @@ -158,7 +158,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1600; - LastUpgradeCheck = 1600; + LastUpgradeCheck = 2600; TargetAttributes = { 56CFC6432C9F1DC9000B5023 = { CreatedOnToolsVersion = 16.0; @@ -293,6 +293,7 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -350,6 +351,7 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; + STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; VALIDATE_PRODUCT = YES; diff --git a/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/xcshareddata/xcschemes/GRDBDemo.xcscheme b/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/xcshareddata/xcschemes/GRDBDemo.xcscheme index 386a9790f..8946129d7 100644 --- a/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/xcshareddata/xcschemes/GRDBDemo.xcscheme +++ b/Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj/xcshareddata/xcschemes/GRDBDemo.xcscheme @@ -1,6 +1,6 @@ (subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { + public func receive(subscriber: S) + where S: Subscriber & GRDBSendableMetatype, + Failure == S.Failure, + Output == S.Input + { let subscription = DatabaseRegionSubscription( writer: writer, observation: observation, @@ -212,7 +216,7 @@ extension DatabasePublishers { private class DatabaseRegionSubscription: Subscription, @unchecked Sendable - where Downstream: Subscriber, + where Downstream: Subscriber & GRDBSendableMetatype, Downstream.Failure == Error, Downstream.Input == Database { diff --git a/GRDB/Documentation.docc/SwiftConcurrency.md b/GRDB/Documentation.docc/SwiftConcurrency.md index 4fcfc15fa..35ce83c57 100644 --- a/GRDB/Documentation.docc/SwiftConcurrency.md +++ b/GRDB/Documentation.docc/SwiftConcurrency.md @@ -229,5 +229,11 @@ Task { } ``` +## Topics + +### Supporting Types + +- ``GRDBSendableMetatype`` + [demo apps]: https://github.com/groue/GRDB.swift/tree/master/Documentation/DemoApps [Migrating to Swift 6]: https://www.swift.org/migration/documentation/migrationguide/ diff --git a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift index 66816236b..c53cca1c0 100644 --- a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift +++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift @@ -362,11 +362,13 @@ extension QueryInterfaceRequest: SelectionRequest { public func selectID() -> QueryInterfaceRequest where RowDecoder: Identifiable { - selectWhenConnected { db in - let primaryKey = try db.primaryKey(self.databaseTableName) + let databaseTableName = self.databaseTableName + + return selectWhenConnected { db in + let primaryKey = try db.primaryKey(databaseTableName) GRDBPrecondition( primaryKey.columns.count == 1, - "selectID requires a single-column primary key in the table \(self.databaseTableName)") + "selectID requires a single-column primary key in the table \(databaseTableName)") return [Column(primaryKey.columns[0])] }.asRequest(of: RowDecoder.ID.self) } diff --git a/GRDB/Record/EncodableRecord.swift b/GRDB/Record/EncodableRecord.swift index 27f995370..98261bc94 100644 --- a/GRDB/Record/EncodableRecord.swift +++ b/GRDB/Record/EncodableRecord.swift @@ -39,7 +39,7 @@ import Foundation // For JSONEncoder /// - ``databaseChanges(from:)`` /// - ``databaseChanges(modify:)`` /// - ``databaseEquals(_:)`` -public protocol EncodableRecord { +public protocol EncodableRecord: GRDBSendableMetatype { /// Encodes the record into the provided persistence container. /// /// In your implementation of this method, store in the `container` argument diff --git a/GRDB/Record/TableRecord.swift b/GRDB/Record/TableRecord.swift index c3a98756b..716b4fc0b 100644 --- a/GRDB/Record/TableRecord.swift +++ b/GRDB/Record/TableRecord.swift @@ -134,7 +134,7 @@ import Foundation /// - ``select(_:as:)-tjh0`` /// - ``updateAll(_:onConflict:_:)-7vv9x`` /// - ``updateAll(_:onConflict:_:)-7atfw`` -public protocol TableRecord { +public protocol TableRecord: GRDBSendableMetatype { /// A type that defines columns. /// /// For example: diff --git a/GRDB/Utils/OnDemandFuture.swift b/GRDB/Utils/OnDemandFuture.swift index 938750d4a..b12840a1d 100644 --- a/GRDB/Utils/OnDemandFuture.swift +++ b/GRDB/Utils/OnDemandFuture.swift @@ -27,7 +27,7 @@ struct OnDemandFuture: Publisher { self.attemptToFulfill = attemptToFulfill } - func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { + func receive(subscriber: S) where S: Subscriber & GRDBSendableMetatype, Failure == S.Failure, Output == S.Input { let subscription = OnDemandFutureSubscription( attemptToFulfill: attemptToFulfill, downstream: subscriber) @@ -35,7 +35,9 @@ struct OnDemandFuture: Publisher { } } -private class OnDemandFutureSubscription: Subscription, @unchecked Sendable { +private class OnDemandFutureSubscription: Subscription, @unchecked Sendable +where Downstream: Subscriber & GRDBSendableMetatype +{ // @unchecked because `state` is protected with `lock`. typealias Promise = @Sendable (Result) -> Void diff --git a/GRDB/Utils/Utils.swift b/GRDB/Utils/Utils.swift index d690b9eec..47bb3a16c 100644 --- a/GRDB/Utils/Utils.swift +++ b/GRDB/Utils/Utils.swift @@ -23,6 +23,16 @@ public func databaseQuestionMarks(count: Int) -> String { repeatElement("?", count: count).joined(separator: ",") } +#if compiler(>=6.2) +/// A synonym for the standard `SendableMetatype` protocol in Swift 6.2, +/// and `Any` in previous compiler versions. +public typealias GRDBSendableMetatype = SendableMetatype +#else +/// A synonym for the standard `SendableMetatype` protocol in Swift 6.2, +/// and `Any` in previous compiler versions. +public typealias GRDBSendableMetatype = Any +#endif + // MARK: - Internal /// Reserved for GRDB: do not use. diff --git a/GRDB/ValueObservation/Reducers/ValueReducer.swift b/GRDB/ValueObservation/Reducers/ValueReducer.swift index 8c7386693..44411cbfb 100644 --- a/GRDB/ValueObservation/Reducers/ValueReducer.swift +++ b/GRDB/ValueObservation/Reducers/ValueReducer.swift @@ -11,7 +11,7 @@ // which is its `Fetcher`. /// Implementation details of `ValueReducer`. -public protocol _ValueReducer { +public protocol _ValueReducer: GRDBSendableMetatype { /// The Sendable type that fetches database values associatedtype Fetcher: _ValueReducerFetcher diff --git a/GRDB/ValueObservation/ValueObservation.swift b/GRDB/ValueObservation/ValueObservation.swift index 92cfe9864..642c2465b 100644 --- a/GRDB/ValueObservation/ValueObservation.swift +++ b/GRDB/ValueObservation/ValueObservation.swift @@ -511,7 +511,11 @@ extension DatabasePublishers { self.start = start } - public func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { + public func receive(subscriber: S) + where S: Subscriber & GRDBSendableMetatype, + Failure == S.Failure, + Output == S.Input + { let subscription = ValueSubscription( start: start, downstream: subscriber) @@ -521,7 +525,7 @@ extension DatabasePublishers { private class ValueSubscription: Subscription, @unchecked Sendable - where Downstream: Subscriber, + where Downstream: Subscriber & GRDBSendableMetatype, Downstream.Failure == Error { // @unchecked Sendable because `cancellable` and `state` are diff --git a/GRDBCustom.xcodeproj/project.pbxproj b/GRDBCustom.xcodeproj/project.pbxproj index 24d55315b..6590d6f98 100755 --- a/GRDBCustom.xcodeproj/project.pbxproj +++ b/GRDBCustom.xcodeproj/project.pbxproj @@ -1880,8 +1880,9 @@ DC3773EA19C8CBB3004FCF85 /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1400; + LastUpgradeCheck = 2600; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { F3BA80591CFB2BB2003DC1BA = { @@ -2555,6 +2556,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -2562,6 +2564,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator"; SUPPORTS_MACCATALYST = YES; @@ -2588,6 +2591,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; GCC_NO_COMMON_BLOCKS = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( @@ -2595,6 +2599,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator"; SUPPORTS_MACCATALYST = YES; diff --git a/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustom.xcscheme b/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustom.xcscheme index e755da341..f4810616a 100644 --- a/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustom.xcscheme +++ b/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustom.xcscheme @@ -1,6 +1,6 @@ //! Project version number for GRDB. FOUNDATION_EXPORT double GRDB_VersionNumber; @@ -8,4 +8,4 @@ FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #import #import -#import "GRDB-Bridging.h" +#import diff --git a/Support/GRDB.h b/Support/GRDB.h index 69ad6ed45..71687094c 100644 --- a/Support/GRDB.h +++ b/Support/GRDB.h @@ -1,4 +1,4 @@ -@import Foundation; +#import //! Project version number for GRDB. FOUNDATION_EXPORT double GRDB_VersionNumber; @@ -7,4 +7,3 @@ FOUNDATION_EXPORT double GRDB_VersionNumber; FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #import - diff --git a/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/xcshareddata/xcschemes/GRDBProfiling.xcscheme b/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/xcshareddata/xcschemes/GRDBProfiling.xcscheme index 143cc0289..c8bc2d0a8 100644 --- a/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/xcshareddata/xcschemes/GRDBProfiling.xcscheme +++ b/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/xcshareddata/xcschemes/GRDBProfiling.xcscheme @@ -1,6 +1,6 @@