diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index cdde29f8bb..71fd0f7614 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -304,7 +304,7 @@ extension Database { let db = Unmanaged.fromOpaque(dbPointer!).takeUnretainedValue() db.configuration.trace!(sql) }, dbPointer) - #else + #elseif !os(Linux) if #available(iOS 10.0, OSX 10.12, watchOS 3.0, *) { sqlite3_trace_v2(sqliteConnection, UInt32(SQLITE_TRACE_STMT), { (mask, dbPointer, stmt, unexpandedSQL) -> Int32 in guard let stmt = stmt else { return SQLITE_OK } @@ -322,6 +322,12 @@ extension Database { db.configuration.trace!(sql) }, dbPointer) } + #else + sqlite3_trace(sqliteConnection, { (dbPointer, sql) in + guard let sql = sql.map({ String(cString: $0) }) else { return } + let db = Unmanaged.fromOpaque(dbPointer!).takeUnretainedValue() + db.configuration.trace!(sql) + }, dbPointer) #endif } diff --git a/GRDB/Core/StatementAuthorizer.swift b/GRDB/Core/StatementAuthorizer.swift index 0808209087..7a2750e43a 100644 --- a/GRDB/Core/StatementAuthorizer.swift +++ b/GRDB/Core/StatementAuthorizer.swift @@ -1,3 +1,6 @@ +#if os(Linux) + import Glibc +#endif #if SWIFT_PACKAGE import CSQLite #elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER diff --git a/GRDB/Core/Support/CoreGraphics/CGFloat.swift b/GRDB/Core/Support/CoreGraphics/CGFloat.swift index 7359eb3fdb..0b7fb1f3ca 100644 --- a/GRDB/Core/Support/CoreGraphics/CGFloat.swift +++ b/GRDB/Core/Support/CoreGraphics/CGFloat.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import CoreGraphics /// CGFloat adopts DatabaseValueConvertible @@ -16,3 +17,4 @@ extension CGFloat : DatabaseValueConvertible { return CGFloat(double) } } +#endif diff --git a/GRDB/Core/Support/Foundation/Date.swift b/GRDB/Core/Support/Foundation/Date.swift index 78cdbbd30f..c5e1e1d6b1 100644 --- a/GRDB/Core/Support/Foundation/Date.swift +++ b/GRDB/Core/Support/Foundation/Date.swift @@ -5,6 +5,7 @@ import Foundation import SQLite3 #endif +#if !os(Linux) /// NSDate is stored in the database using the format /// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone. extension NSDate : DatabaseValueConvertible { @@ -31,6 +32,7 @@ extension NSDate : DatabaseValueConvertible { return cast(date) } } +#endif /// Date is stored in the database using the format /// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone. diff --git a/GRDB/Core/Support/Foundation/NSData.swift b/GRDB/Core/Support/Foundation/NSData.swift index 28a7ae8ba8..8bd9d2ecf9 100644 --- a/GRDB/Core/Support/Foundation/NSData.swift +++ b/GRDB/Core/Support/Foundation/NSData.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation /// NSData is convertible to and from DatabaseValue. @@ -17,3 +18,4 @@ extension NSData : DatabaseValueConvertible { return cast(data) } } +#endif diff --git a/GRDB/Core/Support/Foundation/NSNumber.swift b/GRDB/Core/Support/Foundation/NSNumber.swift index 2a00c16181..2caf60868f 100644 --- a/GRDB/Core/Support/Foundation/NSNumber.swift +++ b/GRDB/Core/Support/Foundation/NSNumber.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation private let integerRoundingBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false) @@ -65,3 +66,4 @@ extension NSNumber : DatabaseValueConvertible { } } } +#endif diff --git a/GRDB/Core/Support/Foundation/NSString.swift b/GRDB/Core/Support/Foundation/NSString.swift index 577725992e..d5455bed45 100644 --- a/GRDB/Core/Support/Foundation/NSString.swift +++ b/GRDB/Core/Support/Foundation/NSString.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation /// NSString adopts DatabaseValueConvertible @@ -16,3 +17,4 @@ extension NSString : DatabaseValueConvertible { return self.init(string: string) } } +#endif diff --git a/GRDB/Core/Support/Foundation/URL.swift b/GRDB/Core/Support/Foundation/URL.swift index 516dcc1fba..4cc95b1b4e 100644 --- a/GRDB/Core/Support/Foundation/URL.swift +++ b/GRDB/Core/Support/Foundation/URL.swift @@ -1,5 +1,6 @@ import Foundation +#if !os(Linux) /// NSURL stores its absoluteString in the database. extension NSURL : DatabaseValueConvertible { @@ -17,6 +18,7 @@ extension NSURL : DatabaseValueConvertible { return cast(URL(string: string)) } } +#endif /// URL stores its absoluteString in the database. extension URL : DatabaseValueConvertible { } diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 5d6d7cfeeb..7deb4e2cfe 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -1,5 +1,6 @@ import Foundation +#if !os(Linux) /// NSUUID adopts DatabaseValueConvertible extension NSUUID : DatabaseValueConvertible { @@ -18,8 +19,9 @@ extension NSUUID : DatabaseValueConvertible { return nil } return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self)) - } + } } +#endif /// UUID adopts DatabaseValueConvertible extension UUID : DatabaseValueConvertible { }