From 7491df5135fdb15db190d6defe4644b5d072c75b Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 15 Jan 2026 12:15:41 -0600 Subject: [PATCH 1/4] Update start behavior for sync engine. --- Sources/SQLiteData/CloudKit/SyncEngine.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SQLiteData/CloudKit/SyncEngine.swift b/Sources/SQLiteData/CloudKit/SyncEngine.swift index 878e832f..588f741e 100644 --- a/Sources/SQLiteData/CloudKit/SyncEngine.swift +++ b/Sources/SQLiteData/CloudKit/SyncEngine.swift @@ -91,7 +91,7 @@ privateTables: repeat (each T2).Type, containerIdentifier: String? = nil, defaultZone: CKRecordZone = CKRecordZone(zoneName: "co.pointfree.SQLiteData.defaultZone"), - startImmediately: Bool = true, + startImmediately: Bool? = nil, delegate: (any SyncEngineDelegate)? = nil, logger: Logger = isTesting ? Logger(.disabled) : Logger(subsystem: "SQLiteData", category: "CloudKit") @@ -152,7 +152,7 @@ privateTables: allPrivateTables ) try setUpSyncEngine() - if startImmediately { + if startImmediately ?? !isTesting { _ = try start() } return @@ -201,7 +201,7 @@ privateTables: allPrivateTables ) try setUpSyncEngine() - if startImmediately { + if startImmediately ?? !isTesting { _ = try start() } } From af15b92c9a48eec8fcecb0153acca2a6cb72dd47 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 15 Jan 2026 12:27:01 -0600 Subject: [PATCH 2/4] wip --- Sources/SQLiteData/CloudKit/SyncEngine.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/SQLiteData/CloudKit/SyncEngine.swift b/Sources/SQLiteData/CloudKit/SyncEngine.swift index 588f741e..32f31036 100644 --- a/Sources/SQLiteData/CloudKit/SyncEngine.swift +++ b/Sources/SQLiteData/CloudKit/SyncEngine.swift @@ -1167,14 +1167,17 @@ } func open(_: some SynchronizableTable) async -> CKRecord? { let row = - withErrorReporting(.sqliteDataCloudKitFailure) { - try userDatabase.read { db in - try T + await withErrorReporting(.sqliteDataCloudKitFailure) { + // NB: Fake 'sending' result. + nonisolated(unsafe) var result: T.QueryOutput? + try await userDatabase.read { db in + result = try T .where { #sql("\($0.primaryKey) = \(bind: metadata.recordPrimaryKey)") } .fetchOne(db) } + return result } ?? nil guard let row From 7d6bf9b7e1872440ce4c0d9127498adcea75ace6 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 15 Jan 2026 12:45:35 -0600 Subject: [PATCH 3/4] wip --- Sources/SQLiteData/CloudKit/CloudKitSharing.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SQLiteData/CloudKit/CloudKitSharing.swift b/Sources/SQLiteData/CloudKit/CloudKitSharing.swift index d36306c8..49e43504 100644 --- a/Sources/SQLiteData/CloudKit/CloudKitSharing.swift +++ b/Sources/SQLiteData/CloudKit/CloudKitSharing.swift @@ -133,7 +133,9 @@ recordPrimaryKey: record.primaryKey.rawIdentifier, reason: .recordMetadataNotFound, debugDescription: """ - No sync metadata found for record. Has the record been saved to the database? + No sync metadata found for record. Has the record been saved to the database \ + and synchronized to iCloud? You can invoke 'SyncEngine.sendChanges()` to force \ + synchronization. """ ) } From d26491459afece832b0cebfb64ee96347945a77a Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Wed, 28 Jan 2026 11:40:52 -0800 Subject: [PATCH 4/4] wip --- Examples/RemindersTests/Internal.swift | 1 + Examples/SyncUpTests/SyncUpFormTests.swift | 1 + Sources/SQLiteData/CloudKit/CloudKitSharing.swift | 2 +- Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/RemindersTests/Internal.swift b/Examples/RemindersTests/Internal.swift index a73dc220..6d763a8f 100644 --- a/Examples/RemindersTests/Internal.swift +++ b/Examples/RemindersTests/Internal.swift @@ -12,6 +12,7 @@ import Testing .dependency(\.uuid, .incrementing), .dependencies { try $0.bootstrapDatabase() + try await $0.defaultSyncEngine.start() try $0.defaultDatabase.seedSampleData() try await $0.defaultSyncEngine.sendChanges() }, diff --git a/Examples/SyncUpTests/SyncUpFormTests.swift b/Examples/SyncUpTests/SyncUpFormTests.swift index df6b6c24..c0f60e96 100644 --- a/Examples/SyncUpTests/SyncUpFormTests.swift +++ b/Examples/SyncUpTests/SyncUpFormTests.swift @@ -10,6 +10,7 @@ import Testing @Suite( .dependencies { try $0.bootstrapDatabase() + try await $0.defaultSyncEngine.start() try await $0.defaultDatabase.seedForTests() $0.uuid = .incrementing } diff --git a/Sources/SQLiteData/CloudKit/CloudKitSharing.swift b/Sources/SQLiteData/CloudKit/CloudKitSharing.swift index 49e43504..1b5cd976 100644 --- a/Sources/SQLiteData/CloudKit/CloudKitSharing.swift +++ b/Sources/SQLiteData/CloudKit/CloudKitSharing.swift @@ -134,7 +134,7 @@ reason: .recordMetadataNotFound, debugDescription: """ No sync metadata found for record. Has the record been saved to the database \ - and synchronized to iCloud? You can invoke 'SyncEngine.sendChanges()` to force \ + and synchronized to iCloud? Invoke 'SyncEngine.sendChanges()' to force \ synchronization. """ ) diff --git a/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift b/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift index 7fff8667..9d6705f4 100644 --- a/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift +++ b/Tests/SQLiteDataTests/CloudKitTests/SharingTests.swift @@ -307,14 +307,14 @@ """ } assertInlineSnapshot(of: error, as: .customDump) { - """ + #""" SyncEngine.SharingError( recordTableName: "remindersLists", recordPrimaryKey: "1", reason: .recordMetadataNotFound, - debugDescription: "No sync metadata found for record. Has the record been saved to the database?" + debugDescription: "No sync metadata found for record. Has the record been saved to the database and synchronized to iCloud? Invoke \'SyncEngine.sendChanges()\' to force synchronization." ) - """ + """# } }