             // > sqlite3_close() will leave the database connection open and
             // > return SQLITE_BUSY.
             let code = sqlite3_close(sqliteConnection)
-            if code != SQLITE_OK {
-                // A rare situation where GRDB doesn't fatalError on
-                // unprocessed errors.
-                if let log = logErrorFunction {
+            #if !SWIFT_PACKAGE
+                if code != SQLITE_OK, let log = logErrorFunction {
+                    // A rare situation where GRDB doesn't fatalError on
+                    // unprocessed errors.
                     let message = String(cString: sqlite3_errmsg(sqliteConnection))
                     log(ResultCode(rawValue: code), "could not close database: \(message)")
                     if code == SQLITE_BUSY {

        case setDefault = "SET DEFAULT"
    }
    
    /// log function that takes an error message.
    public typealias LogErrorFunction = (_ resultCode: ResultCode, _ message: String) -> Void
    
    /// An SQLite threading mode. See https://www.sqlite.org/threadsafe.html.
    enum ThreadingMode {
        case `default`

            // > be deallocated when the last prepared statement is finalized or the
            // > last sqlite3_backup is finished.
            let code = sqlite3_close_v2(sqliteConnection)
            #if !SWIFT_PACKAGE
                if code != SQLITE_OK, let log = logErrorFunction {
                    // A rare situation where GRDB doesn't fatalError on
                    // unprocessed errors.
                    let message = String(cString: sqlite3_errmsg(sqliteConnection))
                    log(ResultCode(rawValue: code), "could not close database: \(message)")
                }
            #endif
        } else {
            // https://www.sqlite.org/c3ref/close.html
            // > If the database connection is associated with unfinalized prepared
