From 0ec3d5478c9fa3e6387ad7cd75cf5b66f4e4e0cb Mon Sep 17 00:00:00 2001 From: Anthony Drendel Date: Wed, 24 Sep 2025 16:52:25 +0200 Subject: [PATCH] Do not listen to lifecycle events on Mac Catalyst --- Sources/SQLite/SQLiteDatabase.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Sources/SQLite/SQLiteDatabase.swift b/Sources/SQLite/SQLiteDatabase.swift index fabf8df..2445300 100644 --- a/Sources/SQLite/SQLiteDatabase.swift +++ b/Sources/SQLite/SQLiteDatabase.swift @@ -45,8 +45,7 @@ public final class SQLiteDatabase: DatabaseProtocol, @unchecked Sendable { public static func makeShared( path: String, busyTimeout: TimeInterval = 5, - collationSequences: [String: @Sendable (String, String) -> ComparisonResult] = [:], - observeLifecycleEvents: Bool = true + collationSequences: [String: @Sendable (String, String) -> ComparisonResult] = [:] ) throws -> SQLiteDatabase { guard path != ":memory:" else { throw SQLiteError.SQLITE_IOERR @@ -72,8 +71,7 @@ public final class SQLiteDatabase: DatabaseProtocol, @unchecked Sendable { database = try SQLiteDatabase( path: url.path, busyTimeout: busyTimeout, - collationSequences: collationSequences, - observeLifecycleEvents: observeLifecycleEvents + collationSequences: collationSequences ) } catch { databaseError = error @@ -97,8 +95,7 @@ public final class SQLiteDatabase: DatabaseProtocol, @unchecked Sendable { public init( path: String = ":memory:", busyTimeout: TimeInterval = 5, - collationSequences: [String: @Sendable (String, String) -> ComparisonResult] = [:], - observeLifecycleEvents: Bool = true + collationSequences: [String: @Sendable (String, String) -> ComparisonResult] = [:] ) throws { database = try Self.open( at: path, @@ -119,9 +116,7 @@ public final class SQLiteDatabase: DatabaseProtocol, @unchecked Sendable { try checkIsSQLiteVersionSupported(sqliteVersion) precondition(enforcesForeignKeyConstraints) - if observeLifecycleEvents { - registerForAppNotifications() - } + registerForAppNotifications() changeNotifier.start() } @@ -547,7 +542,7 @@ public extension SQLiteDatabase { // MARK: - App Notifications -#if canImport(UIKit) +#if canImport(UIKit) && !targetEnvironment(macCatalyst) import UIKit