mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Merge pull request #396 from groue/swift4.2
Support for Xcode 10 and Swift 4.2
This commit is contained in:
17 files changed
+340
-129
No files matched your search
+92
-52
@@ -1,5 +1,5 @@
|
||||
# The OS X Build Environment
|
||||
# https://docs.travis-ci.com/user/reference/osx/#Xcode-version
|
||||
# https://docs.travis-ci.com/user/reference/osx/#xcode-version
|
||||
|
||||
language: objective-c
|
||||
xcode_project: GRDB.xcodeproj
|
||||
@@ -15,29 +15,45 @@ jobs:
|
||||
###########################################
|
||||
## Test GRDB
|
||||
|
||||
# Test GRDBOSX (Xcode 9.4)
|
||||
# Test GRDBOSX (Xcode 10)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBOSX (Xcode 9.4, macOS)
|
||||
script: make test_framework_GRDBOSX
|
||||
- TID=GRDBOSX (Xcode 10, Swift 4.2, macOS)
|
||||
script: make test_framework_GRDBOSX_maxSwift
|
||||
|
||||
# Test GRDBWatchOS (Xcode 9.4)
|
||||
# Test GRDBOSX (Xcode 10)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBWatchOS (Xcode 9.4, watchOS)
|
||||
- TID=GRDBOSX (Xcode 10, Swift 4.0, macOS)
|
||||
script: make test_framework_GRDBOSX_minSwift
|
||||
|
||||
# Test GRDBWatchOS (Xcode 10)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBWatchOS (Xcode 10, watchOS)
|
||||
script: make test_framework_GRDBWatchOS
|
||||
|
||||
# Test GRDBiOS (Xcode 10, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBiOS (Xcode 10, Swift 4.2, iOS <MAX>)
|
||||
script: make test_framework_GRDBiOS_maxTarget_maxSwift
|
||||
|
||||
# Test GRDBiOS (Xcode 9.4, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
env:
|
||||
- TID=GRDBiOS (Xcode 9.4, iOS <MAX>)
|
||||
script: make test_framework_GRDBiOS_maxTarget
|
||||
script: make test_framework_GRDBiOS_maxTarget_maxSwift
|
||||
|
||||
# Test GRDBiOS (Xcode 9.3, iOS <MINIMUM VERSION>))
|
||||
- stage: Test GRDB
|
||||
@@ -47,25 +63,41 @@ jobs:
|
||||
- TID=GRDBiOS (Xcode 9.3, iOS <MIN>)
|
||||
script: make test_framework_GRDBiOS_minTarget
|
||||
|
||||
# Test GRDB [SPM] (Xcode 9.4, macOS)
|
||||
# Test GRDB [SPM] (Xcode 10, macOS)
|
||||
- stage: Test GRDB
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDB [SPM] (Xcode 9.4, macOS)
|
||||
- TID=GRDB [SPM] (Xcode 10, macOS)
|
||||
script: make test_SPM
|
||||
|
||||
###########################################
|
||||
## Test GRDB (Custom SQLite)
|
||||
|
||||
# Test GRDBCustomSQLiteOSX (Xcode 9.4)
|
||||
# Test GRDBCustomSQLiteOSX (Xcode 10)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteOSX (Xcode 9.4, macOS)
|
||||
- TID=GRDBCustomSQLiteOSX (Xcode 10, macOS)
|
||||
script: make test_framework_GRDBCustomSQLiteOSX
|
||||
|
||||
# Test GRDBCustomSQLiteiOS (Xcode 10, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteiOS (Xcode 10, Swift 4.2, iOS <MAX>)
|
||||
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
|
||||
|
||||
# Test GRDBCustomSQLiteiOS (Xcode 10, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBCustomSQLiteiOS (Xcode 10, Swift 4.0, iOS <MAX>)
|
||||
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_minSwift
|
||||
|
||||
# Test GRDBCustomSQLiteiOS (Xcode 9.4, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + Custom SQLite
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
@@ -85,14 +117,22 @@ jobs:
|
||||
###########################################
|
||||
## Test GRDB (SQLCipher)
|
||||
|
||||
# Test GRDBCipherOSX (Xcode 9.4)
|
||||
# Test GRDBCipherOSX (Xcode 10)
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBCipherOSX (Xcode 9.4, macOS)
|
||||
- TID=GRDBCipherOSX (Xcode 10, macOS)
|
||||
script: make test_framework_GRDBCipherOSX
|
||||
|
||||
# Test GRDBCipheriOS (Xcode 10, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=GRDBCipheriOS (Xcode 10, iOS <MAX>)
|
||||
script: make test_framework_GRDBCipheriOS_maxTarget
|
||||
|
||||
# Test GRDBCipheriOS (Xcode 9.4, iOS <MAXIMUM VERSION>)
|
||||
- stage: Test GRDB + SQLCipher
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
@@ -112,88 +152,88 @@ jobs:
|
||||
###########################################
|
||||
## Test Installation Methods
|
||||
|
||||
# Manual Install (Xcode 9.4)
|
||||
# Manual Install (Xcode 10)
|
||||
- stage: Test Installation
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=Manual Install (Xcode 9.4)
|
||||
- TID=Manual Install (Xcode 10)
|
||||
script: make test_install_manual
|
||||
|
||||
# Manual Install (GRDBCipher, Xcode 9.4)
|
||||
# Manual Install (GRDBCipher, Xcode 10)
|
||||
- stage: Test Installation
|
||||
gemfile: .ci/gemfiles/Gemfile.travis
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=Manual Install (GRDBCipher, Xcode 9.4)
|
||||
- TID=Manual Install (GRDBCipher, Xcode 10)
|
||||
script: make test_install_GRDBCipher
|
||||
|
||||
# CocoaPods Lint (Xcode 9.4)
|
||||
# CocoaPods Lint (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods Lint GRDB.swift (Xcode 9.4)
|
||||
- TID=CocoaPods Lint GRDB.swift (Xcode 10)
|
||||
script: make test_CocoaPodsLint_GRDB
|
||||
|
||||
# CocoaPods Lint (Xcode 9.4)
|
||||
# CocoaPods Lint (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods Lint GRDBPlus (Xcode 9.4)
|
||||
- TID=CocoaPods Lint GRDBPlus (Xcode 10)
|
||||
script: make test_CocoaPodsLint_GRDBPlus
|
||||
|
||||
# CocoaPods Lint (Xcode 9.4)
|
||||
# CocoaPods Lint (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods Lint GRDBCipher (Xcode 9.4)
|
||||
- TID=CocoaPods Lint GRDBCipher (Xcode 10)
|
||||
script: make test_CocoaPodsLint_GRDBCipher
|
||||
|
||||
# CocoaPods Install (Xcode 9.4)
|
||||
# CocoaPods Install (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods GRDB (Xcode 9.4)
|
||||
- TID=CocoaPods GRDB (Xcode 10)
|
||||
script: make test_install_GRDB_CocoaPods
|
||||
|
||||
# CocoaPods Install (Xcode 9.4)
|
||||
# CocoaPods Install (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods GRDB+FTS5 (Xcode 9.4)
|
||||
- TID=CocoaPods GRDB+FTS5 (Xcode 10)
|
||||
script: make test_install_GRDBFTS5_CocoaPods
|
||||
|
||||
# CocoaPods Install (Xcode 9.4)
|
||||
# CocoaPods Install (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- gem install cocoapods --pre # >= 1.6.0.beta.1 for cocoapods lint
|
||||
env:
|
||||
- TID=CocoaPods GRDBCipher (Xcode 9.4)
|
||||
- TID=CocoaPods GRDBCipher (Xcode 10)
|
||||
script: make test_install_GRDBCipher_CocoaPods
|
||||
|
||||
# SPM Install (Xcode 9.4)
|
||||
# SPM Install (Xcode 10)
|
||||
- stage: Test Installation
|
||||
osx_image: xcode9.4
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- TID=SPM (Xcode 9.4)
|
||||
- TID=SPM (Xcode 10)
|
||||
script: make test_install_SPM
|
||||
|
||||
## Carthage Build
|
||||
## Commented out until `make test_CarthageBuild` performs *reliably*.
|
||||
## See https://github.com/groue/GRDB.swift/pull/262
|
||||
# - stage: Test Installation
|
||||
# osx_image: xcode9.4
|
||||
# osx_image: xcode10
|
||||
# before_install:
|
||||
# - brew update
|
||||
# - brew outdated carthage || brew upgrade carthage
|
||||
|
||||
@@ -7,6 +7,7 @@ This release focuses on enhancing the relationships between [Codable records](RE
|
||||
|
||||
Other notable enhancements are:
|
||||
|
||||
- Support for Swift 4.2 and Xcode 10
|
||||
- Support for the FTS5 full-text engine when available in the operating system (iOS 11.4+ / macOS 10.13+ / watchOS 4.3+)
|
||||
|
||||
|
||||
|
||||
@@ -3096,7 +3096,7 @@
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
OTHER_SWIFT_FLAGS = "-D GRDB_COMPARE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D GRDB_COMPARE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
@@ -3119,7 +3119,7 @@
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
OTHER_SWIFT_FLAGS = "-D GRDB_COMPARE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D GRDB_COMPARE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
@@ -3275,7 +3275,7 @@
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "-D SQLITE_MODULE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
@@ -3293,7 +3293,7 @@
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "-D SQLITE_MODULE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
@@ -3311,7 +3311,7 @@
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "-D SQLITE_MODULE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
@@ -3329,7 +3329,7 @@
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "-D SQLITE_MODULE";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
|
||||
@@ -577,9 +577,10 @@ struct SchemaInfo: Equatable {
|
||||
var name: String
|
||||
var tbl_name: String?
|
||||
|
||||
// TODO: remove when Hashable conformance is synthesized
|
||||
var hashValue: Int {
|
||||
return type.hashValue ^ name.hashValue ^ (tbl_name?.hashValue ?? 0)
|
||||
}
|
||||
#if !swift(>=4.2)
|
||||
var hashValue: Int {
|
||||
return type.hashValue ^ name.hashValue ^ (tbl_name?.hashValue ?? 0)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -32,17 +32,24 @@ public final class DatabaseCollation {
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseCollation : Hashable {
|
||||
extension DatabaseCollation: Hashable {
|
||||
// Collation equality is based on the sqlite3_strnicmp SQLite function.
|
||||
// (see https://www.sqlite.org/c3ref/create_collation.html). Computing
|
||||
// a hash value that honors the Swift Hashable contract (value equality
|
||||
// implies hash equality) is thus non trivial. But it's not that
|
||||
// important, since this hashValue is only used when one adds
|
||||
// or removes a collation from a database connection.
|
||||
#if swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(0)
|
||||
}
|
||||
#else
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
// Collation equality is based on the sqlite3_strnicmp SQLite function.
|
||||
// (see https://www.sqlite.org/c3ref/create_collation.html). Computing
|
||||
// a hash value that honors the Swift Hashable contract (value equality
|
||||
// implies hash equality) is thus non trivial. But it's not that
|
||||
// important, since this hashValue is only used when one adds
|
||||
// or removes a collation from a database connection.
|
||||
return 0
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Two collations are equal if they share the same name (case insensitive)
|
||||
/// :nodoc:
|
||||
|
||||
@@ -313,11 +313,17 @@ public final class DatabaseFunction: Hashable {
|
||||
}
|
||||
|
||||
extension DatabaseFunction {
|
||||
/// The hash value
|
||||
#if swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(identity)
|
||||
}
|
||||
#else
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return identity.hashValue
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Two functions are equal if they share the same name and arity.
|
||||
/// :nodoc:
|
||||
|
||||
@@ -167,8 +167,13 @@ extension DatabasePool {
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
#if swift(>=4.2)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
#else
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabasePool.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
#endif
|
||||
}
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
@@ -176,10 +181,13 @@ extension DatabasePool {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
let task: UIBackgroundTaskIdentifier = application.beginBackgroundTask(expirationHandler: nil)
|
||||
#if swift(>=4.2)
|
||||
let taskIsInvalid = task == UIBackgroundTaskIdentifier.invalid
|
||||
#else
|
||||
let taskIsInvalid = task == UIBackgroundTaskInvalid
|
||||
#endif
|
||||
if taskIsInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
|
||||
@@ -94,8 +94,13 @@ extension DatabaseQueue {
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
self.application = application
|
||||
let center = NotificationCenter.default
|
||||
#if swift(>=4.2)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||
#else
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidReceiveMemoryWarning(_:)), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
|
||||
center.addObserver(self, selector: #selector(DatabaseQueue.applicationDidEnterBackground(_:)), name: .UIApplicationDidEnterBackground, object: nil)
|
||||
#endif
|
||||
}
|
||||
|
||||
@objc private func applicationDidEnterBackground(_ notification: NSNotification) {
|
||||
@@ -103,10 +108,13 @@ extension DatabaseQueue {
|
||||
return
|
||||
}
|
||||
|
||||
var task: UIBackgroundTaskIdentifier! = nil
|
||||
task = application.beginBackgroundTask(expirationHandler: nil)
|
||||
|
||||
if task == UIBackgroundTaskInvalid {
|
||||
let task: UIBackgroundTaskIdentifier = application.beginBackgroundTask(expirationHandler: nil)
|
||||
#if swift(>=4.2)
|
||||
let taskIsInvalid = task == UIBackgroundTaskIdentifier.invalid
|
||||
#else
|
||||
let taskIsInvalid = task == UIBackgroundTaskInvalid
|
||||
#endif
|
||||
if taskIsInvalid {
|
||||
// Perform releaseMemory() synchronously.
|
||||
releaseMemory()
|
||||
} else {
|
||||
|
||||
@@ -149,7 +149,24 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
|
||||
// Hashable
|
||||
extension DatabaseValue {
|
||||
|
||||
/// The hash value
|
||||
#if swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
switch storage {
|
||||
case .null:
|
||||
hasher.combine(0)
|
||||
case .int64(let int64):
|
||||
// 1 == 1.0, hence 1 and 1.0 must have the same hash:
|
||||
hasher.combine(Double(int64))
|
||||
case .double(let double):
|
||||
hasher.combine(double)
|
||||
case .string(let string):
|
||||
hasher.combine(string)
|
||||
case .blob(let data):
|
||||
hasher.combine(data)
|
||||
}
|
||||
}
|
||||
#else
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
switch storage {
|
||||
@@ -166,6 +183,7 @@ extension DatabaseValue {
|
||||
return data.hashValue
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Returns whether two DatabaseValues are equal.
|
||||
///
|
||||
|
||||
+11
-1
@@ -985,12 +985,22 @@ extension Row {
|
||||
|
||||
// Hashable
|
||||
extension Row {
|
||||
/// The hash value
|
||||
#if swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(count)
|
||||
for (column, dbValue) in self {
|
||||
hasher.combine(column)
|
||||
hasher.combine(dbValue)
|
||||
}
|
||||
}
|
||||
#else
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return columnNames.reduce(0) { (acc, column) in acc ^ column.hashValue } ^
|
||||
databaseValues.reduce(0) { (acc, dbValue) in acc ^ dbValue.hashValue }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// CustomStringConvertible & CustomDebugStringConvertible
|
||||
|
||||
+79
-23
@@ -130,33 +130,89 @@
|
||||
}
|
||||
|
||||
static func api(_ db: Database) -> UnsafePointer<fts5_api> {
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
let sqliteConnection = db.sqliteConnection
|
||||
var statement: SQLiteStatement? = nil
|
||||
var api: UnsafePointer<fts5_api>? = nil
|
||||
let type: StaticString = "fts5_api_ptr"
|
||||
// Access to FTS5 is one of the rare SQLite api which was broken in
|
||||
// SQLite 3.20.0+, for security reasons:
|
||||
//
|
||||
// Starting SQLite 3.20.0+, we need to use the new sqlite3_bind_pointer api.
|
||||
// The previous way to access FTS5 does not work any longer.
|
||||
//
|
||||
// So let's see which SQLite version we are linked against:
|
||||
|
||||
let code = sqlite3_prepare_v3(db.sqliteConnection, "SELECT fts5(?)", -1, 0, &statement, nil)
|
||||
guard code == SQLITE_OK else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
defer { sqlite3_finalize(statement) }
|
||||
type.utf8Start.withMemoryRebound(to: Int8.self, capacity: type.utf8CodeUnitCount) { typePointer in
|
||||
_ = sqlite3_bind_pointer(statement, 1, &api, typePointer, nil)
|
||||
}
|
||||
sqlite3_step(statement)
|
||||
guard let result = api else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
return result
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
// GRDB is linked against SQLCipher or a custom SQLite build: SQLite 3.20.0 or more.
|
||||
return api_v2(db, sqlite3_prepare_v3, sqlite3_bind_pointer)
|
||||
#else
|
||||
// sqlite3_prepare_v3 and sqlite3_bind_pointer are not available yet.
|
||||
guard let data = try! Data.fetchOne(db, "SELECT fts5()") else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
return data.withUnsafeBytes { $0.pointee }
|
||||
// GRDB is linked against the system SQLite.
|
||||
//
|
||||
// Do we use SQLite 3.19.3 (iOS 11.4), or SQLite 3.24.0 (iOS 12.0)?
|
||||
// We need to check for available(iOS 12.0, OSX 10.14, watchOS 5.0, *).
|
||||
//
|
||||
// This test requires the Swift 4.2 compiler.
|
||||
//
|
||||
// It does not need the Swift 4.2 language, though: the Swift 4.2
|
||||
// compiler running in Swift 4.0 compatibility mode is OK.
|
||||
//
|
||||
// On top of that, we want to preserve compatibility with Xcode 9.3+.
|
||||
//
|
||||
// So let's check exactly which compiler version we are using.
|
||||
//
|
||||
// Fortunately, this horribly complex check has been solved
|
||||
// by @hartbit: see https://forums.swift.org/t/compiler-version-directive/11952
|
||||
// and https://github.com/hartbit/swift-evolution/blob/compiler-directive/proposals/XXXX-compiler-version-directive.md
|
||||
#if swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))
|
||||
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
|
||||
// SQLite 3.24.0 or more
|
||||
// setup: Xcode 10.0, SWIFT_VERSION = 4.0, iOS 12
|
||||
// setup: Xcode 10.0, SWIFT_VERSION = 4.2, iOS 12
|
||||
return api_v2(db, sqlite3_prepare_v3, sqlite3_bind_pointer)
|
||||
} else {
|
||||
// SQLite 3.19.3 or less
|
||||
// setup: Xcode 10.0, SWIFT_VERSION = 4.0, iOS 11
|
||||
// setup: Xcode 10.0, SWIFT_VERSION = 4.2, iOS 11
|
||||
return api_v1(db)
|
||||
}
|
||||
#else
|
||||
// SQLite 3.19.3 or less
|
||||
// setup: Xcode 9.4.1, iOS 11
|
||||
return api_v1(db)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
private static func api_v1(_ db: Database) -> UnsafePointer<fts5_api> {
|
||||
guard let data = try! Data.fetchOne(db, "SELECT fts5()") else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
return data.withUnsafeBytes { $0.pointee }
|
||||
}
|
||||
|
||||
// Technique given by Jordan Rose:
|
||||
// https://forums.swift.org/t/c-interoperability-combinations-of-library-and-os-versions/14029/4
|
||||
private static func api_v2(
|
||||
_ db: Database,
|
||||
_ sqlite3_prepare_v3: @convention(c) (OpaquePointer?, UnsafePointer<Int8>?, Int32, UInt32, UnsafeMutablePointer<OpaquePointer?>?, UnsafeMutablePointer<UnsafePointer<Int8>?>?) -> Int32,
|
||||
_ sqlite3_bind_pointer: @convention(c) (OpaquePointer?, Int32, UnsafeMutableRawPointer?, UnsafePointer<Int8>?, (@convention(c) (UnsafeMutableRawPointer?) -> Void)?) -> Int32)
|
||||
-> UnsafePointer<fts5_api>
|
||||
{
|
||||
let sqliteConnection = db.sqliteConnection
|
||||
var statement: SQLiteStatement? = nil
|
||||
var api: UnsafePointer<fts5_api>? = nil
|
||||
let type: StaticString = "fts5_api_ptr"
|
||||
|
||||
let code = sqlite3_prepare_v3(db.sqliteConnection, "SELECT fts5(?)", -1, 0, &statement, nil)
|
||||
guard code == SQLITE_OK else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
defer { sqlite3_finalize(statement) }
|
||||
type.utf8Start.withMemoryRebound(to: Int8.self, capacity: type.utf8CodeUnitCount) { typePointer in
|
||||
_ = sqlite3_bind_pointer(statement, 1, &api, typePointer, nil)
|
||||
}
|
||||
sqlite3_step(statement)
|
||||
guard let result = api else {
|
||||
fatalError("FTS5 is not available")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/// The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.
|
||||
|
||||
@@ -121,20 +121,6 @@ public struct SQLUnaryOperator : Hashable {
|
||||
self.sql = sql
|
||||
self.needsRightSpace = needsRightSpace
|
||||
}
|
||||
|
||||
/// The hash value
|
||||
///
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return sql.hashValue
|
||||
}
|
||||
|
||||
/// Equality operator
|
||||
///
|
||||
/// :nodoc:
|
||||
public static func == (lhs: SQLUnaryOperator, rhs: SQLUnaryOperator) -> Bool {
|
||||
return lhs.sql == rhs.sql
|
||||
}
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
@@ -227,15 +213,17 @@ public struct SQLBinaryOperator : Hashable {
|
||||
return SQLBinaryOperator(negatedSQL, negated: sql)
|
||||
}
|
||||
|
||||
/// The hash value
|
||||
#if !swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return sql.hashValue
|
||||
return sql.hashValue ^ (negatedSQL?.hashValue ?? 0)
|
||||
}
|
||||
|
||||
/// Equality operator
|
||||
/// :nodoc:
|
||||
public static func == (lhs: SQLBinaryOperator, rhs: SQLBinaryOperator) -> Bool {
|
||||
return lhs.sql == rhs.sql
|
||||
return lhs.sql == rhs.sql && lhs.negatedSQL == rhs.negatedSQL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
@@ -235,10 +235,17 @@ public class TableAlias: Hashable {
|
||||
return expression.qualifiedExpression(with: self)
|
||||
}
|
||||
|
||||
#if swift(>=4.2)
|
||||
/// :nodoc:
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(ObjectIdentifier(root))
|
||||
}
|
||||
#else
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return ObjectIdentifier(root).hashValue
|
||||
}
|
||||
#endif
|
||||
|
||||
/// :nodoc:
|
||||
public static func == (lhs: TableAlias, rhs: TableAlias) -> Bool {
|
||||
|
||||
@@ -1185,8 +1185,9 @@ private struct InsertQuery: Hashable {
|
||||
let tableName: String
|
||||
let insertedColumns: [String]
|
||||
|
||||
// TODO: remove when Swift can generate it
|
||||
#if !swift(>=4.2)
|
||||
var hashValue: Int { return tableName.hashValue }
|
||||
#endif
|
||||
}
|
||||
|
||||
extension InsertQuery {
|
||||
@@ -1218,8 +1219,9 @@ private struct UpdateQuery: Hashable {
|
||||
let updatedColumns: [String]
|
||||
let conditionColumns: [String]
|
||||
|
||||
// TODO: remove when Swift can generate it
|
||||
#if !swift(>=4.2)
|
||||
var hashValue: Int { return tableName.hashValue }
|
||||
#endif
|
||||
}
|
||||
|
||||
extension UpdateQuery {
|
||||
|
||||
@@ -45,10 +45,19 @@ XCPRETTY_PATH := $(shell command -v xcpretty 2> /dev/null)
|
||||
TEST_ACTIONS = clean build build-for-testing test-without-building
|
||||
|
||||
# When adding support for an Xcode version, look for available devices with `instruments -s devices`
|
||||
ifeq ($(XCODEVERSION),9.4)
|
||||
ifeq ($(XCODEVERSION),10.0)
|
||||
MIN_SWIFT_VERSION = 4.0
|
||||
MAX_SWIFT_VERSION = 4.2
|
||||
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=12.0"
|
||||
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
|
||||
else ifeq ($(XCODEVERSION),9.4)
|
||||
# MIN_SWIFT_VERSION undefined: only check MAX_SWIFT_VERSION
|
||||
MAX_SWIFT_VERSION = 4.0
|
||||
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.4"
|
||||
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
|
||||
else ifeq ($(XCODEVERSION),9.3)
|
||||
# MIN_SWIFT_VERSION undefined: only check MAX_SWIFT_VERSION
|
||||
MAX_SWIFT_VERSION = 4.0
|
||||
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.3"
|
||||
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
|
||||
else
|
||||
@@ -95,40 +104,72 @@ test_framework_GRDBCipher: test_framework_GRDBCipherOSX test_framework_GRDBCiphe
|
||||
test_install: test_install_manual test_install_GRDBCipher test_install_SPM test_install_GRDB_CocoaPods test_install_GRDBFTS5_CocoaPods test_install_GRDBCipher_CocoaPods test_CocoaPodsLint
|
||||
test_CocoaPodsLint: test_CocoaPodsLint_GRDB test_CocoaPodsLint_GRDBPlus test_CocoaPodsLint_GRDBCipher
|
||||
|
||||
test_framework_GRDBOSX:
|
||||
test_framework_GRDBOSX: test_framework_GRDBOSX_maxSwift test_framework_GRDBOSX_minSwift
|
||||
|
||||
test_framework_GRDBOSX_maxSwift:
|
||||
# SQLITE_ENABLE_FTS5 requires macOS 10.13+
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBOSX \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
test_framework_GRDBOSX_minSwift:
|
||||
ifdef MIN_SWIFT_VERSION
|
||||
# SQLITE_ENABLE_FTS5 requires macOS 10.13+
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBOSX \
|
||||
SWIFT_VERSION=$(MIN_SWIFT_VERSION) \
|
||||
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
endif
|
||||
|
||||
test_framework_GRDBWatchOS:
|
||||
# XCTest is not supported for watchOS: we only make sure that the framework builds.
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBWatchOS \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
clean build \
|
||||
$(XCPRETTY)
|
||||
|
||||
test_framework_GRDBiOS: test_framework_GRDBiOS_maxTarget test_framework_GRDBiOS_minTarget
|
||||
test_framework_GRDBiOS_maxTarget: test_framework_GRDBiOS_maxTarget_maxSwift test_framework_GRDBiOS_maxTarget_minSwift
|
||||
|
||||
test_framework_GRDBiOS_maxTarget:
|
||||
test_framework_GRDBiOS_maxTarget_maxSwift:
|
||||
# SQLITE_ENABLE_FTS5 requires iOS 11.4+
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBiOS \
|
||||
-destination $(MAX_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
test_framework_GRDBiOS_maxTarget_minSwift:
|
||||
ifdef MIN_SWIFT_VERSION
|
||||
# SQLITE_ENABLE_FTS5 requires iOS 11.4+
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBiOS \
|
||||
-destination $(MAX_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MIN_SWIFT_VERSION) \
|
||||
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
endif
|
||||
|
||||
test_framework_GRDBiOS_minTarget:
|
||||
$(XCODEBUILD) \
|
||||
-project GRDB.xcodeproj \
|
||||
-scheme GRDBiOS \
|
||||
-destination $(MIN_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
@@ -136,24 +177,39 @@ test_framework_GRDBCustomSQLiteOSX: SQLiteCustom
|
||||
$(XCODEBUILD) \
|
||||
-project GRDBCustom.xcodeproj \
|
||||
-scheme GRDBCustomSQLiteOSX \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
test_framework_GRDBCustomSQLiteiOS: test_framework_GRDBCustomSQLiteiOS_maxTarget test_framework_GRDBCustomSQLiteiOS_minTarget
|
||||
test_framework_GRDBCustomSQLiteiOS_maxTarget: test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift test_framework_GRDBCustomSQLiteiOS_maxTarget_minSwift
|
||||
|
||||
test_framework_GRDBCustomSQLiteiOS_maxTarget: SQLiteCustom
|
||||
test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift: SQLiteCustom
|
||||
$(XCODEBUILD) \
|
||||
-project GRDBCustom.xcodeproj \
|
||||
-scheme GRDBCustomSQLiteiOS \
|
||||
-destination $(MAX_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
test_framework_GRDBCustomSQLiteiOS_maxTarget_minSwift: SQLiteCustom
|
||||
ifdef MIN_SWIFT_VERSION
|
||||
$(XCODEBUILD) \
|
||||
-project GRDBCustom.xcodeproj \
|
||||
-scheme GRDBCustomSQLiteiOS \
|
||||
-destination $(MAX_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MIN_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
endif
|
||||
|
||||
test_framework_GRDBCustomSQLiteiOS_minTarget: SQLiteCustom
|
||||
$(XCODEBUILD) \
|
||||
-project GRDBCustom.xcodeproj \
|
||||
-scheme GRDBCustomSQLiteiOS \
|
||||
-destination $(MIN_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
@@ -161,6 +217,7 @@ test_framework_GRDBCipherOSX: SQLCipher
|
||||
$(XCODEBUILD) \
|
||||
-project GRDBCipher.xcodeproj \
|
||||
-scheme GRDBCipherOSX \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
@@ -171,6 +228,7 @@ test_framework_GRDBCipheriOS_maxTarget: SQLCipher
|
||||
-project GRDBCipher.xcodeproj \
|
||||
-scheme GRDBCipheriOS \
|
||||
-destination $(MAX_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
@@ -179,6 +237,7 @@ test_framework_GRDBCipheriOS_minTarget: SQLCipher
|
||||
-project GRDBCipher.xcodeproj \
|
||||
-scheme GRDBCipheriOS \
|
||||
-destination $(MIN_IOS_DESTINATION) \
|
||||
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
|
||||
$(TEST_ACTIONS) \
|
||||
$(XCPRETTY)
|
||||
|
||||
|
||||
+1
-1
Submodule SQLCipher/src updated: f18dee2e56...aa6e995ee4.
+1
-1
Submodule SQLiteCustom/src updated: 06de9b66e0...06ba9bdd89.
Reference in new issue
Block a user