From 80956ee2c7c8cb39f8f89c70437e3abb7df08ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 17 Jun 2018 14:03:48 +0200 Subject: [PATCH 01/14] Makefile: support for Xcode 10.0 --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 711bbb528..a05dee107 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,10 @@ 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) + 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) 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) From ff595eeaef39fd010047e050d84c78a3748952b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 2 Aug 2018 17:03:30 +0200 Subject: [PATCH 02/14] Compile with both Swift 4.1 and Swift 4.2 --- GRDB/Core/DatabasePool.swift | 16 ++++++++++++---- GRDB/Core/DatabaseQueue.swift | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index bea877ee3..bb604e734 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -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 { diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 2cad67b1b..5ddaa7ed0 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -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 { From 066889e0d71b6aea19b404d719561f4270c8f36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 7 Aug 2018 07:49:30 +0200 Subject: [PATCH 03/14] Upgrade swiftlyfalling/SQLiteLib --- SQLiteCustom/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLiteCustom/src b/SQLiteCustom/src index 06de9b66e..06ba9bdd8 160000 --- a/SQLiteCustom/src +++ b/SQLiteCustom/src @@ -1 +1 @@ -Subproject commit 06de9b66e0da888dfb9f466d227ea2641a0a086b +Subproject commit 06ba9bdd8961cf37724e895df7c8ed1ea1fd5dd4 From d58586a18ef4d1176a9cae5cde75b3b834c7e7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 7 Aug 2018 08:46:07 +0200 Subject: [PATCH 04/14] Enable FTS5 on iOS 12 Thanks to @jrose-apple for the nice tip that avoids code duplication --- GRDB/FTS/FTS5.swift | 63 +++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/GRDB/FTS/FTS5.swift b/GRDB/FTS/FTS5.swift index 6beaf8451..a7d8a3e95 100644 --- a/GRDB/FTS/FTS5.swift +++ b/GRDB/FTS/FTS5.swift @@ -131,32 +131,51 @@ static func api(_ db: Database) -> UnsafePointer { #if GRDBCUSTOMSQLITE || GRDBCIPHER - let sqliteConnection = db.sqliteConnection - var statement: SQLiteStatement? = nil - var api: UnsafePointer? = 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 + return api2(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") + // Check for sqlite3_prepare_v3 and sqlite3_bind_pointer availability (SQLite 3.20.0) + if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) { + return api2(db, sqlite3_prepare_v3, sqlite3_bind_pointer) + } else { + return api1(db) } - return data.withUnsafeBytes { $0.pointee } #endif } + + private static func api1(_ db: Database) -> UnsafePointer { + 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 api2( + _ db: Database, + _ sqlite3_prepare_v3: @convention(c) (OpaquePointer?, UnsafePointer?, Int32, UInt32, UnsafeMutablePointer?, UnsafeMutablePointer?>?) -> Int32, + _ sqlite3_bind_pointer: @convention(c) (OpaquePointer?, Int32, UnsafeMutableRawPointer?, UnsafePointer?, (@convention(c) (UnsafeMutableRawPointer?) -> Void)?) -> Int32) + -> UnsafePointer + { + let sqliteConnection = db.sqliteConnection + var statement: SQLiteStatement? = nil + var api: UnsafePointer? = 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. From e82c92a00229408bb6f7a726efa38f008f450eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 8 Aug 2018 14:04:44 +0200 Subject: [PATCH 05/14] Allow experiments with OTHER_SWIFT_FLAGS --- GRDB.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 3aeb059f2..f393b8282 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -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; From 83c257822b7d73f0e50be1958c3b542c5060fe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 8 Aug 2018 14:06:57 +0200 Subject: [PATCH 06/14] FTS5: Swift / OS version checks extravaganza With a big thank you to @hartbit for providing a ready-made solution --- GRDB/FTS/FTS5.swift | 55 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/GRDB/FTS/FTS5.swift b/GRDB/FTS/FTS5.swift index a7d8a3e95..fc974b19b 100644 --- a/GRDB/FTS/FTS5.swift +++ b/GRDB/FTS/FTS5.swift @@ -130,19 +130,56 @@ } static func api(_ db: Database) -> UnsafePointer { + // 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: + #if GRDBCUSTOMSQLITE || GRDBCIPHER - return api2(db, sqlite3_prepare_v3, sqlite3_bind_pointer) + // 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 - // Check for sqlite3_prepare_v3 and sqlite3_bind_pointer availability (SQLite 3.20.0) - if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) { - return api2(db, sqlite3_prepare_v3, sqlite3_bind_pointer) - } else { - return api1(db) - } + // 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 api1(_ db: Database) -> UnsafePointer { + private static func api_v1(_ db: Database) -> UnsafePointer { guard let data = try! Data.fetchOne(db, "SELECT fts5()") else { fatalError("FTS5 is not available") } @@ -151,7 +188,7 @@ // Technique given by Jordan Rose: // https://forums.swift.org/t/c-interoperability-combinations-of-library-and-os-versions/14029/4 - private static func api2( + private static func api_v2( _ db: Database, _ sqlite3_prepare_v3: @convention(c) (OpaquePointer?, UnsafePointer?, Int32, UInt32, UnsafeMutablePointer?, UnsafeMutablePointer?>?) -> Int32, _ sqlite3_bind_pointer: @convention(c) (OpaquePointer?, Int32, UnsafeMutableRawPointer?, UnsafePointer?, (@convention(c) (UnsafeMutableRawPointer?) -> Void)?) -> Int32) From 1c09a3d31fbb84651eaed6d36cb3c5553f272fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 8 Aug 2018 14:30:44 +0200 Subject: [PATCH 07/14] New MIN_SWIFT_VERSION and MAX_SWIFT_VERSION makefile variables This allows us to test GRDB with Swift 4.2, but also with the Swift 4.2 compiler in 4.0 compatibility mode. --- .travis.yml | 4 ++-- Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8c6ca790c..17a71e91e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ jobs: osx_image: xcode9.4 env: - TID=GRDBOSX (Xcode 9.4, macOS) - script: make test_framework_GRDBOSX + script: make test_framework_GRDBOSX_maxSwift # Test GRDBWatchOS (Xcode 9.4) - stage: Test GRDB @@ -37,7 +37,7 @@ jobs: osx_image: xcode9.4 env: - TID=GRDBiOS (Xcode 9.4, iOS ) - script: make test_framework_GRDBiOS_maxTarget + script: make test_framework_GRDBiOS_maxTarget_maxSwift # Test GRDBiOS (Xcode 9.3, iOS )) - stage: Test GRDB diff --git a/Makefile b/Makefile index a05dee107..f9e56b470 100644 --- a/Makefile +++ b/Makefile @@ -46,12 +46,18 @@ 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),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 @@ -98,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) @@ -139,6 +177,7 @@ test_framework_GRDBCustomSQLiteOSX: SQLiteCustom $(XCODEBUILD) \ -project GRDBCustom.xcodeproj \ -scheme GRDBCustomSQLiteOSX \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) @@ -149,6 +188,7 @@ test_framework_GRDBCustomSQLiteiOS_maxTarget: SQLiteCustom -project GRDBCustom.xcodeproj \ -scheme GRDBCustomSQLiteiOS \ -destination $(MAX_IOS_DESTINATION) \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) @@ -157,6 +197,7 @@ test_framework_GRDBCustomSQLiteiOS_minTarget: SQLiteCustom -project GRDBCustom.xcodeproj \ -scheme GRDBCustomSQLiteiOS \ -destination $(MIN_IOS_DESTINATION) \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) @@ -164,6 +205,7 @@ test_framework_GRDBCipherOSX: SQLCipher $(XCODEBUILD) \ -project GRDBCipher.xcodeproj \ -scheme GRDBCipherOSX \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) @@ -174,6 +216,7 @@ test_framework_GRDBCipheriOS_maxTarget: SQLCipher -project GRDBCipher.xcodeproj \ -scheme GRDBCipheriOS \ -destination $(MAX_IOS_DESTINATION) \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) @@ -182,6 +225,7 @@ test_framework_GRDBCipheriOS_minTarget: SQLCipher -project GRDBCipher.xcodeproj \ -scheme GRDBCipheriOS \ -destination $(MIN_IOS_DESTINATION) \ + SWIFT_VERSION=$(MAX_SWIFT_VERSION) \ $(TEST_ACTIONS) \ $(XCPRETTY) From e5cd3a89942c9b90786f061a9643f8e679a4651c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 26 Aug 2018 12:48:23 +0200 Subject: [PATCH 08/14] SE-0206 --- GRDB/Core/Database+Schema.swift | 9 +++---- GRDB/Core/DatabaseCollation.swift | 21 ++++++++++------ GRDB/Core/DatabaseFunction.swift | 8 ++++++- GRDB/Core/DatabaseValue.swift | 20 +++++++++++++++- GRDB/Core/Row.swift | 12 +++++++++- .../SQLExpression+QueryInterface.swift | 24 +++++-------------- .../QueryInterface/SQLGenerationContext.swift | 7 ++++++ GRDB/Record/PersistableRecord.swift | 6 +++-- 8 files changed, 73 insertions(+), 34 deletions(-) diff --git a/GRDB/Core/Database+Schema.swift b/GRDB/Core/Database+Schema.swift index fa02bce43..9bbf8a63f 100644 --- a/GRDB/Core/Database+Schema.swift +++ b/GRDB/Core/Database+Schema.swift @@ -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 } } diff --git a/GRDB/Core/DatabaseCollation.swift b/GRDB/Core/DatabaseCollation.swift index 432293690..84d862c78 100644 --- a/GRDB/Core/DatabaseCollation.swift +++ b/GRDB/Core/DatabaseCollation.swift @@ -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: diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index 5cf33ea11..12129f51c 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -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: diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index 6f440c663..4a9b9adaf 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -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. /// diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 1660c509d..11d23e9e9 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -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 diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift index b75f2f533..79bad35e7 100644 --- a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift @@ -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) diff --git a/GRDB/QueryInterface/SQLGenerationContext.swift b/GRDB/QueryInterface/SQLGenerationContext.swift index 1f4a4f33e..491150cd0 100644 --- a/GRDB/QueryInterface/SQLGenerationContext.swift +++ b/GRDB/QueryInterface/SQLGenerationContext.swift @@ -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 { diff --git a/GRDB/Record/PersistableRecord.swift b/GRDB/Record/PersistableRecord.swift index 750c7a547..9c4197a91 100644 --- a/GRDB/Record/PersistableRecord.swift +++ b/GRDB/Record/PersistableRecord.swift @@ -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 { From 3354b22cd06d3ece44e83180d7cd159bee3d8aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 28 Aug 2018 12:49:47 +0200 Subject: [PATCH 09/14] Travis: run tests with Xcode 10 --- .travis.yml | 106 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17a71e91e..04c429507 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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,28 +15,28 @@ 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) + - TID=GRDBOSX (Xcode 10, macOS) script: make test_framework_GRDBOSX_maxSwift - # Test GRDBWatchOS (Xcode 9.4) + # Test GRDBWatchOS (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=GRDBWatchOS (Xcode 10, watchOS) script: make test_framework_GRDBWatchOS - # Test GRDBiOS (Xcode 9.4, iOS ) + # Test GRDBiOS (Xcode 10, iOS ) - stage: Test GRDB gemfile: .ci/gemfiles/Gemfile.travis - osx_image: xcode9.4 + osx_image: xcode10 env: - - TID=GRDBiOS (Xcode 9.4, iOS ) + - TID=GRDBiOS (Xcode 10, iOS ) script: make test_framework_GRDBiOS_maxTarget_maxSwift # Test GRDBiOS (Xcode 9.3, iOS )) @@ -47,31 +47,31 @@ jobs: - TID=GRDBiOS (Xcode 9.3, iOS ) 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 9.4, iOS ) + # Test GRDBCustomSQLiteiOS (Xcode 10, iOS ) - stage: Test GRDB + Custom SQLite gemfile: .ci/gemfiles/Gemfile.travis - osx_image: xcode9.4 + osx_image: xcode10 env: - - TID=GRDBCustomSQLiteiOS (Xcode 9.4, iOS ) + - TID=GRDBCustomSQLiteiOS (Xcode 10, iOS ) script: make test_framework_GRDBCustomSQLiteiOS_maxTarget # Test GRDBCustomSQLiteiOS (Xcode 9.3, iOS )) @@ -85,20 +85,20 @@ 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 9.4, iOS ) + # Test GRDBCipheriOS (Xcode 10, iOS ) - stage: Test GRDB + SQLCipher gemfile: .ci/gemfiles/Gemfile.travis - osx_image: xcode9.4 + osx_image: xcode10 env: - - TID=GRDBCipheriOS (Xcode 9.4, iOS ) + - TID=GRDBCipheriOS (Xcode 10, iOS ) script: make test_framework_GRDBCipheriOS_maxTarget # Test GRDBCipheriOS (Xcode 9.3, iOS )) @@ -112,88 +112,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 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 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 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 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 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 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 From 1c26b7748e98c4867478b2bc141282be9c2b6c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 28 Aug 2018 13:15:19 +0200 Subject: [PATCH 10/14] SQLCipher: Define ARCHS to $ARCHS_STANDARD for all sdks This prevents Xcode 10 beta from outputting errors when it meets the i386 architecture. --- SQLCipher/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLCipher/src b/SQLCipher/src index f18dee2e5..121382f30 160000 --- a/SQLCipher/src +++ b/SQLCipher/src @@ -1 +1 @@ -Subproject commit f18dee2e566f191899027057e11500815f41ba1b +Subproject commit 121382f304ee86ddbb38cb0fe706c8ea810d8e97 From 132ba89427f383d979fdad904e85b38ca77a5f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 29 Aug 2018 08:26:22 +0200 Subject: [PATCH 11/14] Adapt SQLCipher to the new build system --- SQLCipher/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLCipher/src b/SQLCipher/src index 121382f30..aa6e995ee 160000 --- a/SQLCipher/src +++ b/SQLCipher/src @@ -1 +1 @@ -Subproject commit 121382f304ee86ddbb38cb0fe706c8ea810d8e97 +Subproject commit aa6e995ee414056911c468dde3bd0e7d3cbea00e From 8b4eb55568bdcff72240021262168682de042364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 29 Aug 2018 09:49:03 +0200 Subject: [PATCH 12/14] Use Cocoapods pre-release (1.6.0 beta) --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04c429507..b2f1cd6f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -132,7 +132,7 @@ jobs: - stage: Test Installation 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 10) script: make test_CocoaPodsLint_GRDB @@ -141,7 +141,7 @@ jobs: - stage: Test Installation 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 10) script: make test_CocoaPodsLint_GRDBPlus @@ -150,7 +150,7 @@ jobs: - stage: Test Installation 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 10) script: make test_CocoaPodsLint_GRDBCipher @@ -159,7 +159,7 @@ jobs: - stage: Test Installation 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 10) script: make test_install_GRDB_CocoaPods @@ -168,7 +168,7 @@ jobs: - stage: Test Installation 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 10) script: make test_install_GRDBFTS5_CocoaPods @@ -177,7 +177,7 @@ jobs: - stage: Test Installation 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 10) script: make test_install_GRDBCipher_CocoaPods From d9d0f62f710542507049e48a9f7450bcb27a1894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 30 Aug 2018 08:11:13 +0200 Subject: [PATCH 13/14] Travis: please test Swift 4.0, 4.2, and Xcode 9.3, 9.4, and 10. --- .travis.yml | 46 +++++++++++++++++++++++++++++++++++++++++++--- Makefile | 14 +++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2f1cd6f7..b1c9a2116 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,9 +20,17 @@ jobs: gemfile: .ci/gemfiles/Gemfile.travis osx_image: xcode10 env: - - TID=GRDBOSX (Xcode 10, macOS) + - TID=GRDBOSX (Xcode 10, Swift 4.2, macOS) script: make test_framework_GRDBOSX_maxSwift + # Test GRDBOSX (Xcode 10) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode10 + env: + - 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 @@ -36,7 +44,15 @@ jobs: gemfile: .ci/gemfiles/Gemfile.travis osx_image: xcode10 env: - - TID=GRDBiOS (Xcode 10, iOS ) + - TID=GRDBiOS (Xcode 10, Swift 4.2, iOS ) + script: make test_framework_GRDBiOS_maxTarget_maxSwift + + # Test GRDBiOS (Xcode 9.4, iOS ) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode9.4 + env: + - TID=GRDBiOS (Xcode 9.4, iOS ) script: make test_framework_GRDBiOS_maxTarget_maxSwift # Test GRDBiOS (Xcode 9.3, iOS )) @@ -71,7 +87,23 @@ jobs: gemfile: .ci/gemfiles/Gemfile.travis osx_image: xcode10 env: - - TID=GRDBCustomSQLiteiOS (Xcode 10, iOS ) + - TID=GRDBCustomSQLiteiOS (Xcode 10, Swift 4.2, iOS ) + script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift + + # Test GRDBCustomSQLiteiOS (Xcode 10, iOS ) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode10 + env: + - TID=GRDBCustomSQLiteiOS (Xcode 10, Swift 4.0, iOS ) + script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_minSwift + + # Test GRDBCustomSQLiteiOS (Xcode 9.4, iOS ) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode9.4 + env: + - TID=GRDBCustomSQLiteiOS (Xcode 9.4, iOS ) script: make test_framework_GRDBCustomSQLiteiOS_maxTarget # Test GRDBCustomSQLiteiOS (Xcode 9.3, iOS )) @@ -101,6 +133,14 @@ jobs: - TID=GRDBCipheriOS (Xcode 10, iOS ) script: make test_framework_GRDBCipheriOS_maxTarget + # Test GRDBCipheriOS (Xcode 9.4, iOS ) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode9.4 + env: + - TID=GRDBCipheriOS (Xcode 9.4, iOS ) + script: make test_framework_GRDBCipheriOS_maxTarget + # Test GRDBCipheriOS (Xcode 9.3, iOS )) - stage: Test GRDB + SQLCipher gemfile: .ci/gemfiles/Gemfile.travis diff --git a/Makefile b/Makefile index f9e56b470..895fd2bc2 100644 --- a/Makefile +++ b/Makefile @@ -182,8 +182,9 @@ test_framework_GRDBCustomSQLiteOSX: SQLiteCustom $(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 \ @@ -192,6 +193,17 @@ test_framework_GRDBCustomSQLiteiOS_maxTarget: SQLiteCustom $(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 \ From 468eaf86424525a0215a0a0994d7f1414596476a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 31 Aug 2018 08:17:50 +0200 Subject: [PATCH 14/14] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 346f9982e..d2ba3d42d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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+)