diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 98669c7a6..1143bdbf8 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -135,12 +135,12 @@ public final class DatabasePool: DatabaseWriter { // Be a nice iOS citizen, and don't consume too much memory // See https://github.com/groue/GRDB.swift/#memory-management #if os(iOS) - setupAutomaticMemoryManagement() + setupMemoryManagement() #endif } deinit { - // Undo job done in setupAutomaticMemoryManagement() + // Undo job done in setupMemoryManagement() // // https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error // Explicit unregistration is required before iOS 9 and OS X 10.11. @@ -202,14 +202,7 @@ extension DatabasePool { } } - #if os(iOS) - // swiftlint:disable:next line_length - @available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.") - public func setupMemoryManagement(in application: UIApplication) { - // No op. - } - /// Listens to UIApplicationDidEnterBackgroundNotification and /// UIApplicationDidReceiveMemoryWarningNotification in order to release /// as much memory as possible. @@ -217,7 +210,7 @@ extension DatabasePool { /// - param application: The UIApplication that will start a background /// task to let the database pool release its memory when the application /// enters background. - private func setupAutomaticMemoryManagement() { + private func setupMemoryManagement() { let center = NotificationCenter.default center.addObserver( self, diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 4382dddbd..b157f5b2d 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -44,7 +44,7 @@ public final class DatabaseQueue: DatabaseWriter { // Be a nice iOS citizen, and don't consume too much memory // See https://github.com/groue/GRDB.swift/#memory-management #if os(iOS) - setupAutomaticMemoryManagement() + setupMemoryManagement() #endif } @@ -65,7 +65,7 @@ public final class DatabaseQueue: DatabaseWriter { } deinit { - // Undo job done in setupAutomaticMemoryManagement() + // Undo job done in setupMemoryManagement() // // https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error // Explicit unregistration is required before iOS 9 and OS X 10.11. @@ -85,12 +85,6 @@ extension DatabaseQueue { } #if os(iOS) - // swiftlint:disable:next line_length - @available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.") - public func setupMemoryManagement(in application: UIApplication) { - // No op. - } - /// Listens to UIApplicationDidEnterBackgroundNotification and /// UIApplicationDidReceiveMemoryWarningNotification in order to release /// as much memory as possible. @@ -98,7 +92,7 @@ extension DatabaseQueue { /// - param application: The UIApplication that will start a background /// task to let the database queue release its memory when the application /// enters background. - private func setupAutomaticMemoryManagement() { + private func setupMemoryManagement() { let center = NotificationCenter.default center.addObserver( self, diff --git a/GRDB/Fixit/GRDB-5.0.swift b/GRDB/Fixit/GRDB-5.0.swift index 37cfb6f5c..cdb4c5ba0 100644 --- a/GRDB/Fixit/GRDB-5.0.swift +++ b/GRDB/Fixit/GRDB-5.0.swift @@ -1,5 +1,9 @@ // Fixits for changes introduced by GRDB 5.0.0 +#if os(iOS) +import UIKit +#endif + #if SQLITE_HAS_CODEC extension Configuration { @available(*, unavailable, message: "Use Database.usePassphrase(_:) in Configuration.prepareDatabase instead.") @@ -19,3 +23,17 @@ extension DatabaseQueue { public func change(passphrase: String) throws { preconditionFailure() } } #endif + +extension DatabasePool { + #if os(iOS) + @available(*, unavailable, message: "Memory management is now enabled by default. This method does nothing.") + public func setupMemoryManagement(in application: UIApplication) { preconditionFailure() } + #endif +} + +extension DatabaseQueue { + #if os(iOS) + @available(*, unavailable, message: "Memory management is now enabled by default. This method does nothing.") + public func setupMemoryManagement(in application: UIApplication) { preconditionFailure() } + #endif +}