From e44201e0e37e13a2fef58a1547cb8f4f4e0ee616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 25 Feb 2018 09:43:00 +0100 Subject: [PATCH 01/15] Apply advice from @sobri909 --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9caefd747..0d2fecb26 100644 --- a/README.md +++ b/README.md @@ -646,7 +646,16 @@ try dbQueue.inDatabase { db in Both arrays and cursors can iterate over database results. How do you choose one or the other? Look at the differences: -- **Cursors can not be used on any thread**: you must consume a cursor on the dispatch queue it was created in. Arrays may be consumed on any thread. +- **Cursors can not be used on any thread**: you must consume a cursor on the dispatch queue it was created in, and you must not extract it. Arrays may be consumed on any thread: + + ```swift + // Wrong + let cursor = try dbQueue.inDatabase { try Player.fetchCursor($0, ...) } + + // OK + let array = try dbQueue.inDatabase { try Player.fetchAll($0, ...) } + ``` + - **Cursors can be iterated only one time.** Arrays can be iterated many times. - **Cursors iterate database results in a lazy fashion**, and don't consume much memory. Arrays contain copies of database values, and may take a lot of memory when there are many fetched results. - **Cursors are granted with direct access to SQLite,** unlike arrays that have to take the time to copy database values. When you really care about performance, you may want to deal with cursors of raw rows at the lowest possible level: `Row.fetchCursor(...)`. From f2462d42702e1c2aec99a85dafa2a02257d885c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 2 Mar 2018 18:56:43 +0100 Subject: [PATCH 02/15] Improve Record overview --- README.md | 68 ++++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 0d2fecb26..afc278044 100644 --- a/README.md +++ b/README.md @@ -1923,14 +1923,12 @@ player.name = "Arthur" try player.update(db) ``` -Records can [track their changes](#changes-tracking), so that you can avoid useless updates: +It is possible to [avoid useless updates](#changes-tracking): ```swift let player = try Player.fetchOne(db, key: 1)! player.name = "Arthur" -if player.hasDatabaseChanges { - try player.update(db) -} +try player.updateChanges(db) ``` For batch updates, execute an [SQL query](#executing-updates): @@ -1957,7 +1955,7 @@ try Player.deleteOne(db, key: ["email": "arthur@example.com"]) try Country.deleteAll(db, keys: ["FR", "US"]) ``` -For batch deletes, see the [query interface](#the-query-interface): +For batch deletes, execute an [SQL query](#executing-updates), or see the [query interface](#the-query-interface): ```swift try Player.filter(emailColumn == nil).deleteAll(db) @@ -1993,25 +1991,14 @@ Details follow: - [RowConvertible](#rowconvertible-protocol) is able to **read**: it grants the ability to efficiently decode raw database row. - Imagine you want to load places from the `places` database table. - - One way to do it is to load raw database rows: + You can always decode rows yourself: ```swift - func fetchPlaceRows(_ db: Database) throws -> [Row] { - return try Row.fetchAll(db, "SELECT * FROM places") - } - ``` - - The problem is that [raw rows](#row-queries) are not easy to deal with, and you may prefer using a proper `Place` type: - - ```swift - // Dedicated model struct Place { ... } - func fetchPlaces(_ db: Database) throws -> [Place] { + try dbQueue.inDatabase { db in let rows = try Row.fetchAll(db, "SELECT * FROM places") - return rows.map { row in - Place( + let places: [Place] = rows.map { row in + return Place( id: row["id"], title: row["title"], coordinate: CLLocationCoordinate2D( @@ -2022,45 +2009,16 @@ Details follow: } ``` - This code is verbose, and so you define an `init(row:)` initializer: + But RowConvertible lets you write code that is much more readable, and much more efficient as well, both in terms of performance and memory usage: ```swift - // Row initializer - struct Place { - init(row: Row) { - id = row["id"] - ... - } - } - func fetchPlaces(_ db: Database) throws -> [Place] { - let rows = try Row.fetchAll(db, "SELECT * FROM places") - return rows.map { Place(row: $0) } + struct Place: FetchableRecord { ... } + try dbQueue.inDatabase { db in + let places = try Place.fetchAll(db, "SELECT * FROM places") } ``` - Now you notice that this code may use a lot of memory when you have many rows: a full array of database rows is created in order to build an array of places. Furthermore, rows that have been copied from the database have lost the ability to directly load values from SQLite: that's inefficient. You thus use a [database cursor](#cursors), which is both lazy and efficient: - - ```swift - // Cursor for efficiency - func fetchPlaces(_ db: Database) throws -> [Place] { - let rowCursor = try Row.fetchCursor(db, "SELECT * FROM places") - let placeCursor = rowCursor.map { Place(row: $0) } - return try Array(placeCursor) - } - ``` - - That's better. And that's what RowConvertible does, with a little performance bonus, and in a single line: - - ```swift - struct Place : RowConvertible { - init(row: Row) { ... } - } - func fetchPlaces(_ db: Database) throws -> [Place] { - return try Place.fetchAll(db, "SELECT * FROM places") - } - ``` - - RowConvertible is not able to build SQL requests, though. For that, you also need TableMapping: + RowConvertible is not able to build SQL requests for you, though. For that, you also need TableMapping: - [TableMapping](#tablemapping-protocol) is able to **build requests without SQL**: @@ -2089,6 +2047,8 @@ Details follow: try Place(...).insert(db) } ``` + + A persistable record can also [compare](#changes-tracking) itself against other records, and avoid useless database updates. ## RowConvertible Protocol From ad0f6de809b97203df88326d2cb370c726b0531a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 11:31:47 +0100 Subject: [PATCH 03/15] Fix Xcode9.3 warnings --- .../GRDBDemoiOS.xcodeproj/project.pbxproj | 163 ++-------------- .../xcschemes/GRDBDemoWatchOS.xcscheme | 2 +- .../xcschemes/GRDBDemoiOS.xcscheme | 2 +- GRDB.xcodeproj/project.pbxproj | 30 ++- .../xcshareddata/xcschemes/GRDBOSX.xcscheme | 6 +- ...GRDBOSXPerformanceComparisonTests.xcscheme | 4 +- .../GRDBOSXPerformanceTests.xcscheme | 4 +- .../xcschemes/GRDBWatchOS.xcscheme | 2 +- .../xcshareddata/xcschemes/GRDBiOS.xcscheme | 6 +- GRDBCipher.xcodeproj/project.pbxproj | 25 ++- .../xcschemes/GRDBCipherOSX.xcscheme | 4 +- .../xcschemes/GRDBCipheriOS.xcscheme | 4 +- GRDBCustom.xcodeproj/project.pbxproj | 19 +- .../xcschemes/GRDBCustomSQLiteOSX.xcscheme | 13 +- .../xcschemes/GRDBCustomSQLiteiOS.xcscheme | 8 +- .../GRDBProfiling.xcodeproj/project.pbxproj | 174 +++--------------- 16 files changed, 132 insertions(+), 334 deletions(-) diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj index c4acc4319..4ae785152 100644 --- a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj +++ b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj @@ -94,41 +94,6 @@ remoteGlobalIDString = 56553C181C3E906C00522B5C; remoteInfo = GRDBOSXCrashTests; }; - 56B036421E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 560FC54D1CB003810014AA8E; - remoteInfo = GRDBCipherOSX; - }; - 56B036441E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 560FC5B01CB00B880014AA8E; - remoteInfo = GRDBCipherOSXTests; - }; - 56B036461E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 5671566C1CB16729007DC145; - remoteInfo = GRDBCipherOSXEncryptedTests; - }; - 56B036481E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA805A1CFB2BB2003DC1BA; - remoteInfo = GRDBCustomSQLiteOSX; - }; - 56B0364A1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA809B1CFB2F6F003DC1BA; - remoteInfo = GRDBCustomSQLiteOSXTests; - }; 56B0364C1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; @@ -143,41 +108,6 @@ remoteGlobalIDString = 56E5D7D31B4D3FEE00430942; remoteInfo = GRDBiOSTests; }; - 56B036501E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCA231CB1A8BB00F48B96; - remoteInfo = GRDBCipheriOS; - }; - 56B036521E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCA7F1CB1AA9900F48B96; - remoteInfo = GRDBCipheriOSTests; - }; - 56B036541E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCAD71CB1ABC800F48B96; - remoteInfo = GRDBCipheriOSEncryptedTests; - }; - 56B036561E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA7FFE1CFB25E4003DC1BA; - remoteInfo = GRDBCustomSQLiteiOS; - }; - 56B036581E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA80411CFB2AD7003DC1BA; - remoteInfo = GRDBCustomSQLiteiOSTests; - }; 56B0365A1E8D9F79003B6DA4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 56B036261E8D9F79003B6DA4 /* GRDB.xcodeproj */; @@ -369,18 +299,8 @@ 56B0363F1E8D9F79003B6DA4 /* GRDBOSXPerformanceTests.xctest */, 563BD2F11F8364C1006A5390 /* GRDBOSXPerformanceComparisonTests.xctest */, 56B036411E8D9F79003B6DA4 /* GRDBOSXCrashTests.xctest */, - 56B036431E8D9F79003B6DA4 /* GRDBCipher.framework */, - 56B036451E8D9F79003B6DA4 /* GRDBCipherOSXTests.xctest */, - 56B036471E8D9F79003B6DA4 /* GRDBCipherOSXEncryptedTests.xctest */, - 56B036491E8D9F79003B6DA4 /* GRDBCustomSQLite.framework */, - 56B0364B1E8D9F79003B6DA4 /* GRDBCustomSQLiteOSXTests.xctest */, 56B0364D1E8D9F79003B6DA4 /* GRDB.framework */, 56B0364F1E8D9F79003B6DA4 /* GRDBiOSTests.xctest */, - 56B036511E8D9F79003B6DA4 /* GRDBCipher.framework */, - 56B036531E8D9F79003B6DA4 /* GRDBCipheriOSTests.xctest */, - 56B036551E8D9F79003B6DA4 /* GRDBCipheriOSEncryptedTests.xctest */, - 56B036571E8D9F79003B6DA4 /* GRDBCustomSQLite.framework */, - 56B036591E8D9F79003B6DA4 /* GRDBCustomSQLiteiOSTests.xctest */, 56B0365B1E8D9F79003B6DA4 /* GRDB.framework */, ); name = Products; @@ -455,7 +375,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { 568E5FBE1E926430002582E0 = { @@ -537,41 +457,6 @@ remoteRef = 56B036401E8D9F79003B6DA4 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 56B036431E8D9F79003B6DA4 /* GRDBCipher.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCipher.framework; - remoteRef = 56B036421E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036451E8D9F79003B6DA4 /* GRDBCipherOSXTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipherOSXTests.xctest; - remoteRef = 56B036441E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036471E8D9F79003B6DA4 /* GRDBCipherOSXEncryptedTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipherOSXEncryptedTests.xctest; - remoteRef = 56B036461E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036491E8D9F79003B6DA4 /* GRDBCustomSQLite.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCustomSQLite.framework; - remoteRef = 56B036481E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B0364B1E8D9F79003B6DA4 /* GRDBCustomSQLiteOSXTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCustomSQLiteOSXTests.xctest; - remoteRef = 56B0364A1E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 56B0364D1E8D9F79003B6DA4 /* GRDB.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -586,41 +471,6 @@ remoteRef = 56B0364E1E8D9F79003B6DA4 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 56B036511E8D9F79003B6DA4 /* GRDBCipher.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCipher.framework; - remoteRef = 56B036501E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036531E8D9F79003B6DA4 /* GRDBCipheriOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipheriOSTests.xctest; - remoteRef = 56B036521E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036551E8D9F79003B6DA4 /* GRDBCipheriOSEncryptedTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipheriOSEncryptedTests.xctest; - remoteRef = 56B036541E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036571E8D9F79003B6DA4 /* GRDBCustomSQLite.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCustomSQLite.framework; - remoteRef = 56B036561E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 56B036591E8D9F79003B6DA4 /* GRDBCustomSQLiteiOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCustomSQLiteiOSTests.xctest; - remoteRef = 56B036581E8D9F79003B6DA4 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 56B0365B1E8D9F79003B6DA4 /* GRDB.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -751,6 +601,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; @@ -767,6 +618,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; @@ -784,6 +636,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; IBSC_MODULE = GRDBDemoWatchOS_Extension; INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist; @@ -801,6 +654,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; IBSC_MODULE = GRDBDemoWatchOS_Extension; INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist; @@ -827,6 +681,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -834,6 +689,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -883,6 +739,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -890,6 +747,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -912,6 +770,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; @@ -923,6 +782,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; INFOPLIST_FILE = GRDBDemoiOS/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -936,6 +796,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; DEVELOPMENT_TEAM = AMD8W895CT; INFOPLIST_FILE = GRDBDemoiOS/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/xcshareddata/xcschemes/GRDBDemoWatchOS.xcscheme b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/xcshareddata/xcschemes/GRDBDemoWatchOS.xcscheme index 70ba69fe8..16013f9a2 100644 --- a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/xcshareddata/xcschemes/GRDBDemoWatchOS.xcscheme +++ b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/xcshareddata/xcschemes/GRDBDemoWatchOS.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSXPerformanceComparisonTests.xcscheme b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSXPerformanceComparisonTests.xcscheme index dc203d353..fc3be5e0e 100644 --- a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSXPerformanceComparisonTests.xcscheme +++ b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSXPerformanceComparisonTests.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/GRDBCipher.xcodeproj/project.pbxproj b/GRDBCipher.xcodeproj/project.pbxproj index 97c210416..5c5a9aa79 100755 --- a/GRDBCipher.xcodeproj/project.pbxproj +++ b/GRDBCipher.xcodeproj/project.pbxproj @@ -1879,7 +1879,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { 560FC5191CB003810014AA8E = { @@ -2810,6 +2810,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -2830,6 +2831,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -2839,6 +2841,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2847,6 +2850,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; GCC_NO_COMMON_BLOCKS = YES; @@ -2863,6 +2867,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -2873,6 +2878,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2881,6 +2887,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; GCC_NO_COMMON_BLOCKS = YES; @@ -2897,6 +2904,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -2907,6 +2915,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2918,6 +2927,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEBUG_INFORMATION_FORMAT = dwarf; @@ -2942,6 +2952,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; COPY_PHASE_STRIP = NO; @@ -2955,6 +2966,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2964,6 +2976,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEBUG_INFORMATION_FORMAT = dwarf; GCC_NO_COMMON_BLOCKS = YES; @@ -2980,6 +2993,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -2990,6 +3004,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2998,6 +3013,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEBUG_INFORMATION_FORMAT = dwarf; GCC_NO_COMMON_BLOCKS = YES; @@ -3014,6 +3030,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 56C494411ED7269800CC72AF /* GRDBDeploymentTarget.xcconfig */; buildSettings = { + CLANG_ENABLE_OBJC_WEAK = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -3024,6 +3041,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSEncryptedTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3040,12 +3058,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -3093,12 +3113,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -3119,6 +3141,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; diff --git a/GRDBCipher.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme b/GRDBCipher.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme index 6ab046b60..1586943d3 100644 --- a/GRDBCipher.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme +++ b/GRDBCipher.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme @@ -1,6 +1,6 @@ + + + + diff --git a/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustomSQLiteiOS.xcscheme b/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustomSQLiteiOS.xcscheme index 7a6690b89..0a3a1bb1c 100644 --- a/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustomSQLiteiOS.xcscheme +++ b/GRDBCustom.xcodeproj/xcshareddata/xcschemes/GRDBCustomSQLiteiOS.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -71,7 +70,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/project.pbxproj b/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/project.pbxproj index 7400ab318..f67b4bf18 100644 --- a/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/project.pbxproj +++ b/Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj/project.pbxproj @@ -45,41 +45,6 @@ remoteGlobalIDString = 56553C181C3E906C00522B5C; remoteInfo = GRDBOSXCrashTests; }; - 564C5B6F1F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 560FC54D1CB003810014AA8E; - remoteInfo = GRDBCipherOSX; - }; - 564C5B711F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 560FC5B01CB00B880014AA8E; - remoteInfo = GRDBCipherOSXTests; - }; - 564C5B731F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 5671566C1CB16729007DC145; - remoteInfo = GRDBCipherOSXEncryptedTests; - }; - 564C5B751F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA805A1CFB2BB2003DC1BA; - remoteInfo = GRDBCustomSQLiteOSX; - }; - 564C5B771F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA809B1CFB2F6F003DC1BA; - remoteInfo = GRDBCustomSQLiteOSXTests; - }; 564C5B791F489B8A00176870 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; @@ -94,41 +59,6 @@ remoteGlobalIDString = 56E5D7D31B4D3FEE00430942; remoteInfo = GRDBiOSTests; }; - 564C5B7D1F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCA231CB1A8BB00F48B96; - remoteInfo = GRDBCipheriOS; - }; - 564C5B7F1F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCA7F1CB1AA9900F48B96; - remoteInfo = GRDBCipheriOSTests; - }; - 564C5B811F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 56AFCAD71CB1ABC800F48B96; - remoteInfo = GRDBCipheriOSEncryptedTests; - }; - 564C5B831F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA7FFE1CFB25E4003DC1BA; - remoteInfo = GRDBCustomSQLiteiOS; - }; - 564C5B851F489B8A00176870 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = F3BA80411CFB2AD7003DC1BA; - remoteInfo = GRDBCustomSQLiteiOSTests; - }; 564C5B871F489B8A00176870 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; @@ -136,6 +66,13 @@ remoteGlobalIDString = 565490A01D5A4798005622CB; remoteInfo = GRDBWatchOS; }; + 56B1C3BD201C8B7D001938DA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 56537C841BA8874F00E87787 /* GRDB.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 56439B501F4CA1DC0066043F; + remoteInfo = GRDBOSXPerformanceComparisonTests; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -182,19 +119,10 @@ 564C5B681F489B8A00176870 /* GRDB.framework */, 564C5B6A1F489B8A00176870 /* GRDBOSXTests.xctest */, 564C5B6C1F489B8A00176870 /* GRDBOSXPerformanceTests.xctest */, + 56B1C3BE201C8B7D001938DA /* GRDBOSXPerformanceComparisonTests.xctest */, 564C5B6E1F489B8A00176870 /* GRDBOSXCrashTests.xctest */, - 564C5B701F489B8A00176870 /* GRDBCipher.framework */, - 564C5B721F489B8A00176870 /* GRDBCipherOSXTests.xctest */, - 564C5B741F489B8A00176870 /* GRDBCipherOSXEncryptedTests.xctest */, - 564C5B761F489B8A00176870 /* GRDBCustomSQLite.framework */, - 564C5B781F489B8A00176870 /* GRDBCustomSQLiteOSXTests.xctest */, 564C5B7A1F489B8A00176870 /* GRDB.framework */, 564C5B7C1F489B8A00176870 /* GRDBiOSTests.xctest */, - 564C5B7E1F489B8A00176870 /* GRDBCipher.framework */, - 564C5B801F489B8A00176870 /* GRDBCipheriOSTests.xctest */, - 564C5B821F489B8A00176870 /* GRDBCipheriOSEncryptedTests.xctest */, - 564C5B841F489B8A00176870 /* GRDBCustomSQLite.framework */, - 564C5B861F489B8A00176870 /* GRDBCustomSQLiteiOSTests.xctest */, 564C5B881F489B8A00176870 /* GRDB.framework */, ); name = Products; @@ -258,7 +186,7 @@ 56537C6A1BA8871A00E87787 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { 56537C711BA8871A00E87787 = { @@ -320,41 +248,6 @@ remoteRef = 564C5B6D1F489B8A00176870 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 564C5B701F489B8A00176870 /* GRDBCipher.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCipher.framework; - remoteRef = 564C5B6F1F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B721F489B8A00176870 /* GRDBCipherOSXTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipherOSXTests.xctest; - remoteRef = 564C5B711F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B741F489B8A00176870 /* GRDBCipherOSXEncryptedTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipherOSXEncryptedTests.xctest; - remoteRef = 564C5B731F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B761F489B8A00176870 /* GRDBCustomSQLite.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCustomSQLite.framework; - remoteRef = 564C5B751F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B781F489B8A00176870 /* GRDBCustomSQLiteOSXTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCustomSQLiteOSXTests.xctest; - remoteRef = 564C5B771F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 564C5B7A1F489B8A00176870 /* GRDB.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -369,41 +262,6 @@ remoteRef = 564C5B7B1F489B8A00176870 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 564C5B7E1F489B8A00176870 /* GRDBCipher.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCipher.framework; - remoteRef = 564C5B7D1F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B801F489B8A00176870 /* GRDBCipheriOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipheriOSTests.xctest; - remoteRef = 564C5B7F1F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B821F489B8A00176870 /* GRDBCipheriOSEncryptedTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCipheriOSEncryptedTests.xctest; - remoteRef = 564C5B811F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B841F489B8A00176870 /* GRDBCustomSQLite.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = GRDBCustomSQLite.framework; - remoteRef = 564C5B831F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 564C5B861F489B8A00176870 /* GRDBCustomSQLiteiOSTests.xctest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = GRDBCustomSQLiteiOSTests.xctest; - remoteRef = 564C5B851F489B8A00176870 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 564C5B881F489B8A00176870 /* GRDB.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -411,6 +269,13 @@ remoteRef = 564C5B871F489B8A00176870 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 56B1C3BE201C8B7D001938DA /* GRDBOSXPerformanceComparisonTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = GRDBOSXPerformanceComparisonTests.xctest; + remoteRef = 56B1C3BD201C8B7D001938DA /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -462,12 +327,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -514,12 +381,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -550,6 +419,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = GRDBProfiling/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; @@ -563,11 +433,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = GRDBProfiling/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBProfiling; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 3.0; }; From 85d3c584ef7e754add7e66af2176e97d3c69f899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 12:09:51 +0100 Subject: [PATCH 04/15] Swift 4.1 compatibility (SE-0184 , SE-0187) --- GRDB.xcodeproj/project.pbxproj | 16 ++++++++-------- GRDB/Core/DatabaseFunction.swift | 2 +- .../Foundation/DatabaseDateComponents.swift | 2 +- GRDB/Core/TransactionObserver.swift | 4 ++-- GRDB/Legacy/Swift4.1.swift | 16 ++++++++++++++++ GRDB/QueryInterface/TableDefinition.swift | 2 +- GRDB/Record/RowConvertible+Decodable.swift | 2 +- GRDBCipher.xcodeproj/project.pbxproj | 6 ++++++ GRDBCustom.xcodeproj/project.pbxproj | 6 ++++++ Tests/GRDBTests/DatabaseAggregateTests.swift | 4 ++++ Tests/GRDBTests/DatabaseFunctionTests.swift | 4 ++++ .../QueryInterfaceExpressionsTests.swift | 4 ++++ 12 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 GRDB/Legacy/Swift4.1.swift diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index eb73b43ab..25c15e753 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -423,6 +423,9 @@ 56B021CD1D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B021C81D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift */; }; 56B14E831D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B14E7E1D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift */; }; 56B15D0B1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; }; + 56B1C3CD201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; }; + 56B1C3CE201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; }; + 56B1C3CF201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; }; 56B7F42A1BE14A1900E39BBF /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; }; 56B7F43A1BEB42D500E39BBF /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; }; 56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; }; @@ -940,6 +943,7 @@ 56B021C81D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistablePersistenceConflictPolicyTests.swift; sourceTree = ""; }; 56B14E7E1D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromDictionaryLiteralTests.swift; sourceTree = ""; }; 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = ""; }; + 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = ""; }; 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = ""; }; 56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = ""; }; 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.0.3/Realm.framework"; sourceTree = ""; }; @@ -1612,6 +1616,7 @@ 56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */, 56D121591ED34978001347D2 /* Fixits-0.109.0.swift */, 56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */, + 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */, ); path = Legacy; sourceTree = ""; @@ -2252,6 +2257,7 @@ 565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */, 565490B81D5AE236005622CB /* DatabaseError.swift in Sources */, 56BF6D3C1DEF47DA006039A3 /* Fixits-0-90-1.swift in Sources */, + 56B1C3CF201C8D0E001938DA /* Swift4.1.swift in Sources */, 56DAA2E11DE9C827006E10C8 /* Cursor.swift in Sources */, 565490BC1D5AE236005622CB /* DatabaseSchemaCache.swift in Sources */, 565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */, @@ -2330,6 +2336,7 @@ 5674A7081F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */, 56A2388C1B9C75030082EB20 /* Statement.swift in Sources */, 5659F4931EA8D964004A4992 /* ReadWriteBox.swift in Sources */, + 56B1C3CE201C8D0E001938DA /* Swift4.1.swift in Sources */, 5605F1941C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */, 56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */, 5690C3431D23E82A00E59934 /* Data.swift in Sources */, @@ -2735,6 +2742,7 @@ 5605F1931C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */, 566B912B1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */, 56A2388B1B9C75030082EB20 /* Statement.swift in Sources */, + 56B1C3CD201C8D0E001938DA /* Swift4.1.swift in Sources */, 5690C3401D23E82A00E59934 /* Data.swift in Sources */, 5659F4881EA8D94E004A4992 /* Utils.swift in Sources */, 56FC98781D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */, @@ -2840,7 +2848,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2886,7 +2893,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Performance/GRDBPerformanceComparisonTests-Bridging.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; @@ -2974,7 +2980,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3025,7 +3030,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3063,7 +3067,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3100,7 +3103,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3200,7 +3202,6 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; @@ -3247,7 +3248,6 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; - SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index 8de8d1ed4..a0443c87d 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -274,7 +274,7 @@ public final class DatabaseFunction { let aggregateContextU = Unmanaged.passRetained(aggregateContext) var aggregateContextP = aggregateContextU.toOpaque() withUnsafeBytes(of: &aggregateContextP) { - aggregateContextBufferP.copyBytes(from: $0) + aggregateContextBufferP.copyMemory(from: $0) } return aggregateContextU } diff --git a/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift b/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift index 1e1385a85..93d7978d4 100644 --- a/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift +++ b/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift @@ -105,7 +105,7 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { timeString = nil } - return [dateString, timeString].flatMap { $0 }.joined(separator: " ").databaseValue + return [dateString, timeString].compactMap { $0 }.joined(separator: " ").databaseValue } /// Returns a DatabaseDateComponents if *dbValue* contains a diff --git a/GRDB/Core/TransactionObserver.swift b/GRDB/Core/TransactionObserver.swift index 0d3f0bfe5..00df65ec3 100644 --- a/GRDB/Core/TransactionObserver.swift +++ b/GRDB/Core/TransactionObserver.swift @@ -238,7 +238,7 @@ class DatabaseObservationBroker { // For example, if one observes all deletions in the table T, then // all individual deletions of DELETE FROM T are notified: let eventKind = eventKinds[0] - statementObservations = transactionObservations.flatMap { observation in + statementObservations = transactionObservations.compactMap { observation in guard observation.observes(eventsOfKind: eventKind) else { // observation is not interested return nil @@ -260,7 +260,7 @@ class DatabaseObservationBroker { // For example, if DELETE FROM T1 generates deletions in T1 and T2 // by the mean of a foreign key action, then when one only observes // deletions in T1, one must not be notified of deletions in T2: - statementObservations = transactionObservations.flatMap { observation in + statementObservations = transactionObservations.compactMap { observation in let observedKinds = eventKinds.filter(observation.observes) if observedKinds.isEmpty { // observation is not interested diff --git a/GRDB/Legacy/Swift4.1.swift b/GRDB/Legacy/Swift4.1.swift new file mode 100644 index 000000000..1d125c78e --- /dev/null +++ b/GRDB/Legacy/Swift4.1.swift @@ -0,0 +1,16 @@ +// Compatibility layer for Swift < 4.1 + +#if swift(>=4.1) +#else +extension Sequence { + func compactMap(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { + return try flatMap(transform) + } +} + +extension UnsafeMutableRawBufferPointer { + func copyMemory(from source: C) where C : Collection, C.Element == UInt8 { + copyBytes(from: source) + } +} +#endif diff --git a/GRDB/QueryInterface/TableDefinition.swift b/GRDB/QueryInterface/TableDefinition.swift index 9a3242973..52b704542 100644 --- a/GRDB/QueryInterface/TableDefinition.swift +++ b/GRDB/QueryInterface/TableDefinition.swift @@ -463,7 +463,7 @@ public final class TableDefinition { } let indexStatements = columns - .flatMap { $0.indexDefinition(in: name) } + .compactMap { $0.indexDefinition(in: name) } .map { $0.sql() } statements.append(contentsOf: indexStatements) return statements.joined(separator: "; ") diff --git a/GRDB/Record/RowConvertible+Decodable.swift b/GRDB/Record/RowConvertible+Decodable.swift index c63ae9942..b8ba94af2 100644 --- a/GRDB/Record/RowConvertible+Decodable.swift +++ b/GRDB/Record/RowConvertible+Decodable.swift @@ -14,7 +14,7 @@ private struct RowKeyedDecodingContainer: KeyedDecodingContainer let row = decoder.row let columnNames = Set(row.columnNames) let scopeNames = row.scopeNames - return columnNames.union(scopeNames).flatMap { Key(stringValue: $0) } + return columnNames.union(scopeNames).compactMap { Key(stringValue: $0) } } /// Returns whether the `Decoder` contains a value associated with the given key. diff --git a/GRDBCipher.xcodeproj/project.pbxproj b/GRDBCipher.xcodeproj/project.pbxproj index 5c5a9aa79..56d9918cb 100755 --- a/GRDBCipher.xcodeproj/project.pbxproj +++ b/GRDBCipher.xcodeproj/project.pbxproj @@ -482,6 +482,8 @@ 5698AD251DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */; }; 5698AD361DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; }; 5698AD391DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; }; + 569B7FA8201C904C0069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA6201C904C0069DE70 /* Swift4.1.swift */; }; + 569B7FA9201C904C0069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA6201C904C0069DE70 /* Swift4.1.swift */; }; 569C1EB31CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; }; 569C1EB41CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; }; 569C1EB61CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; }; @@ -974,6 +976,7 @@ 5698AD151DAAD16F0056AF8C /* FTS5Tokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5Tokenizer.swift; sourceTree = ""; }; 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5WrapperTokenizer.swift; sourceTree = ""; }; 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5CustomTokenizer.swift; sourceTree = ""; }; + 569B7FA6201C904C0069DE70 /* Swift4.1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = ""; }; 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulingWatchdogTests.swift; sourceTree = ""; }; 569EF0E8200D387000A9FA45 /* DatabaseRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegion.swift; sourceTree = ""; }; 56A238131B9C74A90082EB20 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = ""; }; @@ -1607,6 +1610,7 @@ 56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */, 56D121591ED34978001347D2 /* Fixits-0.109.0.swift */, 56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */, + 569B7FA6201C904C0069DE70 /* Swift4.1.swift */, ); path = Legacy; sourceTree = ""; @@ -2013,6 +2017,7 @@ 5698AC381D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, 564F9C2F1F07611400877A00 /* DatabaseFunction.swift in Sources */, 5659F4991EA8D989004A4992 /* Pool.swift in Sources */, + 569B7FA8201C904C0069DE70 /* Swift4.1.swift in Sources */, 5674A6FA1F307F600095F066 /* Persistable+Encodable.swift in Sources */, 56CEB54D1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, 5664759B1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, @@ -2407,6 +2412,7 @@ 5698AC3B1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, 564F9C321F07611700877A00 /* DatabaseFunction.swift in Sources */, 5659F49C1EA8D989004A4992 /* Pool.swift in Sources */, + 569B7FA9201C904C0069DE70 /* Swift4.1.swift in Sources */, 5674A6F71F307F600095F066 /* Persistable+Encodable.swift in Sources */, 56CEB5501EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, 5664759E1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, diff --git a/GRDBCustom.xcodeproj/project.pbxproj b/GRDBCustom.xcodeproj/project.pbxproj index 8770937ee..314f5d50d 100755 --- a/GRDBCustom.xcodeproj/project.pbxproj +++ b/GRDBCustom.xcodeproj/project.pbxproj @@ -189,6 +189,8 @@ 5698AD261DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */; }; 5698AD371DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; }; 5698AD3A1DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; }; + 569B7FA4201C90430069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA2201C90430069DE70 /* Swift4.1.swift */; }; + 569B7FA5201C90430069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA2201C90430069DE70 /* Swift4.1.swift */; }; 569EF0E6200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */; }; 569EF0E7200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */; }; 56A4CDB31D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A4CDAF1D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift */; }; @@ -667,6 +669,7 @@ 5698AD151DAAD16F0056AF8C /* FTS5Tokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5Tokenizer.swift; sourceTree = ""; }; 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5WrapperTokenizer.swift; sourceTree = ""; }; 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5CustomTokenizer.swift; sourceTree = ""; }; + 569B7FA2201C90430069DE70 /* Swift4.1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = ""; }; 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulingWatchdogTests.swift; sourceTree = ""; }; 569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegion.swift; sourceTree = ""; }; 56A238131B9C74A90082EB20 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = ""; }; @@ -1279,6 +1282,7 @@ 56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */, 56D121591ED34978001347D2 /* Fixits-0.109.0.swift */, 56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */, + 569B7FA2201C90430069DE70 /* Swift4.1.swift */, ); path = Legacy; sourceTree = ""; @@ -1714,6 +1718,7 @@ F3BA80101CFB2876003DC1BA /* DatabaseReader.swift in Sources */, 564F9C331F07611800877A00 /* DatabaseFunction.swift in Sources */, 5659F49D1EA8D989004A4992 /* Pool.swift in Sources */, + 569B7FA5201C90430069DE70 /* Swift4.1.swift in Sources */, 5674A6F61F307F600095F066 /* Persistable+Encodable.swift in Sources */, 56CEB5511EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, 5698AC3C1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, @@ -1960,6 +1965,7 @@ F3BA806C1CFB2E55003DC1BA /* DatabaseReader.swift in Sources */, 564F9C301F07611500877A00 /* DatabaseFunction.swift in Sources */, 5659F49A1EA8D989004A4992 /* Pool.swift in Sources */, + 569B7FA4201C90430069DE70 /* Swift4.1.swift in Sources */, 5674A6F51F307F600095F066 /* Persistable+Encodable.swift in Sources */, 56CEB54E1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, 5698AC391D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, diff --git a/Tests/GRDBTests/DatabaseAggregateTests.swift b/Tests/GRDBTests/DatabaseAggregateTests.swift index ad0657436..faf882210 100644 --- a/Tests/GRDBTests/DatabaseAggregateTests.swift +++ b/Tests/GRDBTests/DatabaseAggregateTests.swift @@ -295,7 +295,11 @@ class DatabaseAggregateTests: GRDBTestCase { struct Aggregate : DatabaseAggregate { var result: DatabaseValueConvertible? mutating func step(_ dbValues: [DatabaseValue]) { + #if swift(>=4.1) + let ints = dbValues.compactMap { Int.fromDatabaseValue($0) } + #else let ints = dbValues.flatMap { Int.fromDatabaseValue($0) } + #endif result = ints.reduce(0, +) } func finalize() -> DatabaseValueConvertible? { diff --git a/Tests/GRDBTests/DatabaseFunctionTests.swift b/Tests/GRDBTests/DatabaseFunctionTests.swift index 48cd9f874..4fd02a4b7 100644 --- a/Tests/GRDBTests/DatabaseFunctionTests.swift +++ b/Tests/GRDBTests/DatabaseFunctionTests.swift @@ -250,7 +250,11 @@ class DatabaseFunctionTests: GRDBTestCase { func testFunctionOfTwoArguments() throws { let dbQueue = try makeDatabaseQueue() let fn = DatabaseFunction("f", argumentCount: 2) { dbValues in + #if swift(>=4.1) + let ints = dbValues.compactMap { Int.fromDatabaseValue($0) } + #else let ints = dbValues.flatMap { Int.fromDatabaseValue($0) } + #endif return ints.reduce(0, +) } dbQueue.add(function: fn) diff --git a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift index daa2c3e1e..2dbdfa946 100644 --- a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift +++ b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift @@ -31,7 +31,11 @@ class QueryInterfaceExpressionsTests: GRDBTestCase { dbWriter.add(collation: collation) customFunction = DatabaseFunction("avgOf", pure: true) { dbValues in + #if swift(>=4.1) + let sum = dbValues.compactMap { Int.fromDatabaseValue($0) }.reduce(0, +) + #else let sum = dbValues.flatMap { Int.fromDatabaseValue($0) }.reduce(0, +) + #endif return Double(sum) / Double(dbValues.count) } dbWriter.add(function: self.customFunction) From 75d5c2a39f1fa1f3bad37c9da15dc09c16ab9c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 12:19:59 +0100 Subject: [PATCH 05/15] SE-0187: deprecate Cursor.flatMap in favor of Cursor.compactMap --- GRDB/Core/Cursor.swift | 13 +++++++++++++ Tests/GRDBTests/CursorTests.swift | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/GRDB/Core/Cursor.swift b/GRDB/Core/Cursor.swift index 26ca0b362..7afea0a74 100644 --- a/GRDB/Core/Cursor.swift +++ b/GRDB/Core/Cursor.swift @@ -132,11 +132,24 @@ extension Cursor { return nil } + #if swift(>=4.1) + /// Returns a cursor over the concatenated non-nil results of mapping + /// transform over this cursor. + public func compactMap(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor>, ElementOfResult> { + return map(transform).filter { $0 != nil }.map { $0! } + } + + @available(*, deprecated, renamed: "compactMap") + public func flatMap(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor>, ElementOfResult> { + return compactMap(transform) + } + #else /// Returns a cursor over the concatenated non-nil results of mapping /// transform over this cursor. public func flatMap(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor>, ElementOfResult> { return map(transform).filter { $0 != nil }.map { $0! } } + #endif /// Returns a cursor that skips any initial elements that satisfy /// `predicate`. diff --git a/Tests/GRDBTests/CursorTests.swift b/Tests/GRDBTests/CursorTests.swift index 19c9370e3..81debde5d 100644 --- a/Tests/GRDBTests/CursorTests.swift +++ b/Tests/GRDBTests/CursorTests.swift @@ -78,12 +78,21 @@ class CursorTests: GRDBTestCase { } } + #if swift(>=4.1) + func testCompactMap() { + let cursor = IteratorCursor(["1", "foo", "2"]).compactMap { Int($0) } + XCTAssertEqual(try cursor.next()!, 1) + XCTAssertEqual(try cursor.next()!, 2) + XCTAssertTrue(try cursor.next() == nil) // end + } + #else func testFlatMapOfOptional() { let cursor = IteratorCursor(["1", "foo", "2"]).flatMap { Int($0) } XCTAssertEqual(try cursor.next()!, 1) XCTAssertEqual(try cursor.next()!, 2) XCTAssertTrue(try cursor.next() == nil) // end } + #endif func testForEach() throws { let cursor = IteratorCursor([1, 2]) From a75e519294c751d126ac0c79ba3fcb2a4adb7849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 12:39:40 +0100 Subject: [PATCH 06/15] SE-0185: let Swift 4.1 generate as much Equatable and Hashable conformance as possible --- GRDB/Core/Database.swift | 6 +++ GRDB/Core/DatabaseError.swift | 3 ++ GRDB/Core/DatabaseFunction.swift | 44 ++++++++++++------- GRDB/Core/DatabaseRegion.swift | 3 ++ GRDB/Core/Statement.swift | 3 ++ .../SQLExpression+QueryInterface.swift | 3 ++ GRDB/Record/FetchedRecordsController.swift | 7 +-- GRDB/Record/Persistable.swift | 20 +++++---- 8 files changed, 63 insertions(+), 26 deletions(-) diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 9a8f4c8eb..0e0097db7 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -841,11 +841,14 @@ extension Database { self.rawValue = rawValue } + #if swift(>=4.1) + #else /// The hash value /// :nodoc: public var hashValue: Int { return rawValue.hashValue } + #endif /// The `BINARY` built-in SQL collation public static let binary = CollationName("BINARY") @@ -878,11 +881,14 @@ extension Database { self.rawValue = rawValue } + #if swift(>=4.1) + #else /// The hash value /// :nodoc: public var hashValue: Int { return rawValue.hashValue } + #endif /// The `TEXT` SQL column type public static let text = ColumnType("TEXT") diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 6833c383f..4c6b39256 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -139,6 +139,8 @@ public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8))) } +#if swift(>=4.1) +#else // Equatable extension ResultCode { /// :nodoc: @@ -146,6 +148,7 @@ extension ResultCode { return lhs.rawValue == rhs.rawValue } } +#endif // CustomStringConvertible extension ResultCode { diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index a0443c87d..702913cf7 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -5,12 +5,28 @@ #endif /// An SQL function or aggregate. -public final class DatabaseFunction { - public let name: String - let argumentCount: Int32? +public final class DatabaseFunction: Hashable { + // SQLite identifies functions by (name + argument count) + private struct Identity: Hashable { + let name: String + let nArg: Int32 // -1 for variadic functions + + #if swift(>=4.1) + #else + var hashValue: Int { + return name.hashValue ^ nArg.hashValue + } + + static func == (lhs: Identity, rhs: Identity) -> Bool { + return lhs.name == rhs.name && lhs.nArg == rhs.nArg + } + #endif + } + + public var name: String { return identity.name } + private let identity: Identity let pure: Bool private let kind: Kind - private var nArg: Int32 { return argumentCount ?? -1 } private var eTextRep: Int32 { return (SQLITE_UTF8 | (pure ? SQLITE_DETERMINISTIC : 0)) } /// Returns an SQL function. @@ -38,8 +54,7 @@ public final class DatabaseFunction { /// exactly *argumentCount* elements, provided *argumentCount* is /// not nil. public init(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, function: @escaping ([DatabaseValue]) throws -> DatabaseValueConvertible?) { - self.name = name - self.argumentCount = argumentCount + self.identity = Identity(name: name, nArg: argumentCount ?? -1) self.pure = pure self.kind = .function{ (argc, argv) in let arguments = (0..(_ name: String, argumentCount: Int32? = nil, pure: Bool = false, aggregate: Aggregate.Type) { - self.name = name - self.argumentCount = argumentCount + self.identity = Identity(name: name, nArg: argumentCount ?? -1) self.pure = pure self.kind = .aggregate { return Aggregate() } } @@ -104,8 +118,8 @@ public final class DatabaseFunction { let code = sqlite3_create_function_v2( db.sqliteConnection, - name, - nArg, + identity.name, + identity.nArg, eTextRep, definitionP, kind.xFunc, @@ -127,8 +141,8 @@ public final class DatabaseFunction { func uninstall(in db: Database) { let code = sqlite3_create_function_v2( db.sqliteConnection, - name, - nArg, + identity.name, + identity.nArg, eTextRep, nil, nil, nil, nil, nil) @@ -309,17 +323,17 @@ public final class DatabaseFunction { } } -extension DatabaseFunction : Hashable { +extension DatabaseFunction { /// The hash value /// :nodoc: public var hashValue: Int { - return name.hashValue ^ nArg.hashValue + return identity.hashValue } /// Two functions are equal if they share the same name and arity. /// :nodoc: public static func == (lhs: DatabaseFunction, rhs: DatabaseFunction) -> Bool { - return lhs.name == rhs.name && lhs.nArg == rhs.nArg + return lhs.identity == rhs.identity } } diff --git a/GRDB/Core/DatabaseRegion.swift b/GRDB/Core/DatabaseRegion.swift index 52f67a6fb..8d4b140ad 100644 --- a/GRDB/Core/DatabaseRegion.swift +++ b/GRDB/Core/DatabaseRegion.swift @@ -255,11 +255,14 @@ private struct TableRegion: Equatable { return false } + #if swift(>=4.1) + #else static func == (lhs: TableRegion, rhs: TableRegion) -> Bool { if lhs.columns != rhs.columns { return false } if lhs.rowIds != rhs.rowIds { return false } return true } + #endif func intersection(_ other: TableRegion) -> TableRegion { let columnsIntersection: Set? diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index f29a1536f..dbbcf86e8 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -911,6 +911,8 @@ extension StatementArguments { } } +#if swift(>=4.1) +#else // Equatable extension StatementArguments { /// :nodoc: @@ -920,6 +922,7 @@ extension StatementArguments { return true } } +#endif /// A thread-unsafe statement cache struct StatementCache { diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift index 786ec9a5d..825774fde 100644 --- a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift @@ -486,6 +486,8 @@ public struct SQLFunctionName : Hashable { self.sql = sql } + #if swift(>=4.1) + #else /// The hash value /// /// :nodoc: @@ -499,6 +501,7 @@ public struct SQLFunctionName : Hashable { public static func == (lhs: SQLFunctionName, rhs: SQLFunctionName) -> Bool { return lhs.sql == rhs.sql } + #endif } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) diff --git a/GRDB/Record/FetchedRecordsController.swift b/GRDB/Record/FetchedRecordsController.swift index 03dd53490..9d23f784b 100644 --- a/GRDB/Record/FetchedRecordsController.swift +++ b/GRDB/Record/FetchedRecordsController.swift @@ -1050,8 +1050,9 @@ private final class Item : RowConvertible, Equatable { init(row: Row) { self.row = row.copy() } + + static func == (lhs: Item, rhs: Item) -> Bool { + return lhs.row == rhs.row + } } -private func == (lhs: Item, rhs: Item) -> Bool { - return lhs.row == rhs.row -} diff --git a/GRDB/Record/Persistable.swift b/GRDB/Record/Persistable.swift index 002e78175..824617966 100644 --- a/GRDB/Record/Persistable.swift +++ b/GRDB/Record/Persistable.swift @@ -977,20 +977,22 @@ final class DAO { // MARK: - InsertQuery -private struct InsertQuery { +private struct InsertQuery: Hashable { let onConflict: Database.ConflictResolution let tableName: String let insertedColumns: [String] -} - -extension InsertQuery : Hashable { + + // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } + #if swift(>=4.1) + #else static func == (lhs: InsertQuery, rhs: InsertQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } return lhs.insertedColumns == rhs.insertedColumns } + #endif } extension InsertQuery { @@ -1016,22 +1018,24 @@ extension InsertQuery { // MARK: - UpdateQuery -private struct UpdateQuery { +private struct UpdateQuery: Hashable { let onConflict: Database.ConflictResolution let tableName: String let updatedColumns: [String] let conditionColumns: [String] -} - -extension UpdateQuery : Hashable { + + // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } + #if swift(>=4.1) + #else static func == (lhs: UpdateQuery, rhs: UpdateQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } if lhs.updatedColumns != rhs.updatedColumns { return false } return lhs.conditionColumns == rhs.conditionColumns } + #endif } extension UpdateQuery { From 1d28ca1fcae90de90a5a8242ea0089641c9e4c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 12:41:38 +0100 Subject: [PATCH 07/15] TODO Swift 4.1 --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.md b/TODO.md index f0baf3825..2c043996f 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,10 @@ - [ ] Allow concurrent reads from a snapshot - [ ] Decode NSDecimalNumber from text database values +Xcode 9.3, Swift 4.1 + +- [ ] Audit Cursor return types and make it look as much as possible as stdlib's lazy sequence + GRDB 3.0 - [ ] Rename "changes tracking" (ambiguous with database observation) to "record comparison" From bca1fe0d9b0298e8cdd6ccd3ba8d22150f013901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 13:03:34 +0100 Subject: [PATCH 08/15] SE-0184: backport UnsafeMutablePointer.deallocate() --- GRDB/FTS/FTS5Tokenizer.swift | 4 ++-- GRDB/Legacy/Swift4.1.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/GRDB/FTS/FTS5Tokenizer.swift b/GRDB/FTS/FTS5Tokenizer.swift index dcb01d7f7..20efcdad3 100644 --- a/GRDB/FTS/FTS5Tokenizer.swift +++ b/GRDB/FTS/FTS5Tokenizer.swift @@ -192,10 +192,10 @@ let api = FTS5.api(self) let xTokenizerPointer: UnsafeMutablePointer = .allocate(capacity: 1) - defer { xTokenizerPointer.deallocate(capacity: 1) } + defer { xTokenizerPointer.deallocate() } let contextHandle: UnsafeMutablePointer = .allocate(capacity: 1) - defer { contextHandle.deallocate(capacity: 1) } + defer { contextHandle.deallocate() } let code = api.pointee.xFindTokenizer!( UnsafeMutablePointer(mutating: api), diff --git a/GRDB/Legacy/Swift4.1.swift b/GRDB/Legacy/Swift4.1.swift index 1d125c78e..418865e83 100644 --- a/GRDB/Legacy/Swift4.1.swift +++ b/GRDB/Legacy/Swift4.1.swift @@ -3,12 +3,21 @@ #if swift(>=4.1) #else extension Sequence { + // From future import SE-0187 func compactMap(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { return try flatMap(transform) } } +extension UnsafeMutablePointer { + // From future import SE-0184 + func deallocate() { + deallocate(capacity: 0) + } +} + extension UnsafeMutableRawBufferPointer { + // From future import SE-0184 func copyMemory(from source: C) where C : Collection, C.Element == UInt8 { copyBytes(from: source) } From 9505ba16067f12c365c39a6647227d4cd2ca908d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 27 Jan 2018 13:13:49 +0100 Subject: [PATCH 09/15] Replace flatMap with compactMap in README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index afc278044..8a627e387 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ GRDB 2 [![Swift](https://img.shields.io/badge/swift-4-orange.svg?style=flat)](ht **Latest release**: February 25, 2018 • version 2.9.0 • [CHANGELOG](CHANGELOG.md) -**Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4.0 / Xcode 9+ +**Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4+ / Xcode 9+ | Swift version | GRDB version | | ------------- | ----------------------------------------------------------- | @@ -675,7 +675,7 @@ Both arrays and cursors can iterate over database results. How do you choose one If you don't see, or don't care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate. -**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: +**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: ```swift // All URL hosts @@ -1509,7 +1509,7 @@ When you don't provide any explicit *argumentCount*, the function can take any n ```swift let averageOf = DatabaseFunction("averageOf", pure: true) { (values: [DatabaseValue]) in - let doubles = values.flatMap { Double.fromDatabaseValue($0) } + let doubles = values.compactMap { Double.fromDatabaseValue($0) } return doubles.reduce(0, +) / Double(doubles.count) } dbQueue.add(function: averageOf) From 1cbe60a13f205b8043598e8d105cbac83fa5cf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 12 Mar 2018 18:33:06 +0100 Subject: [PATCH 10/15] Better checks for Swift < 4.1 (thanks @hartbit!) --- GRDB/Core/Database.swift | 6 ++---- GRDB/Core/DatabaseError.swift | 3 +-- GRDB/Core/DatabaseFunction.swift | 3 +-- GRDB/Core/DatabaseRegion.swift | 3 +-- GRDB/Core/Statement.swift | 3 +-- GRDB/Legacy/Swift4.1.swift | 3 +-- GRDB/QueryInterface/SQLExpression+QueryInterface.swift | 3 +-- GRDB/Record/Persistable.swift | 6 ++---- 8 files changed, 10 insertions(+), 20 deletions(-) diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 0e0097db7..ad48f304e 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -841,8 +841,7 @@ extension Database { self.rawValue = rawValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// :nodoc: public var hashValue: Int { @@ -881,8 +880,7 @@ extension Database { self.rawValue = rawValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// :nodoc: public var hashValue: Int { diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 4c6b39256..afa6cb5d9 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -139,8 +139,7 @@ public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8))) } -#if swift(>=4.1) -#else +#if !swift(>=4.1) // Equatable extension ResultCode { /// :nodoc: diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index 702913cf7..873a3e922 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -11,8 +11,7 @@ public final class DatabaseFunction: Hashable { let name: String let nArg: Int32 // -1 for variadic functions - #if swift(>=4.1) - #else + #if !swift(>=4.1) var hashValue: Int { return name.hashValue ^ nArg.hashValue } diff --git a/GRDB/Core/DatabaseRegion.swift b/GRDB/Core/DatabaseRegion.swift index 8d4b140ad..678144fbf 100644 --- a/GRDB/Core/DatabaseRegion.swift +++ b/GRDB/Core/DatabaseRegion.swift @@ -255,8 +255,7 @@ private struct TableRegion: Equatable { return false } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: TableRegion, rhs: TableRegion) -> Bool { if lhs.columns != rhs.columns { return false } if lhs.rowIds != rhs.rowIds { return false } diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index dbbcf86e8..e0bf95f60 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -911,8 +911,7 @@ extension StatementArguments { } } -#if swift(>=4.1) -#else +#if !swift(>=4.1) // Equatable extension StatementArguments { /// :nodoc: diff --git a/GRDB/Legacy/Swift4.1.swift b/GRDB/Legacy/Swift4.1.swift index 418865e83..c1adaac2f 100644 --- a/GRDB/Legacy/Swift4.1.swift +++ b/GRDB/Legacy/Swift4.1.swift @@ -1,7 +1,6 @@ // Compatibility layer for Swift < 4.1 -#if swift(>=4.1) -#else +#if !swift(>=4.1) extension Sequence { // From future import SE-0187 func compactMap(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift index 825774fde..ce34318f3 100644 --- a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift @@ -486,8 +486,7 @@ public struct SQLFunctionName : Hashable { self.sql = sql } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// /// :nodoc: diff --git a/GRDB/Record/Persistable.swift b/GRDB/Record/Persistable.swift index 824617966..f511f3346 100644 --- a/GRDB/Record/Persistable.swift +++ b/GRDB/Record/Persistable.swift @@ -985,8 +985,7 @@ private struct InsertQuery: Hashable { // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: InsertQuery, rhs: InsertQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } @@ -1027,8 +1026,7 @@ private struct UpdateQuery: Hashable { // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: UpdateQuery, rhs: UpdateQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } From afd2d25e5e55ebe4d5b57b6811d5f376d04fb829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 30 Mar 2018 07:21:49 +0200 Subject: [PATCH 11/15] Makefile: add support for Xcode 9.3 --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6f17fe493..e8012b004 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,10 @@ TEST_ACTIONS = clean build build-for-testing test-without-building # xcodebuild destination to run tests on iOS 8.1 (requires a pre-installed simulator) MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=8.1" -ifeq ($(XCODEVERSION),9.2) +# When adding support for an Xcode version, look for available devices with `instruments -s devices` +ifeq ($(XCODEVERSION),9.3) + MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.3" +else ifeq ($(XCODEVERSION),9.2) MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.2" else ifeq ($(XCODEVERSION),9.1) MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.1" From f9a806d9aa901995df0a14c6f78d7bd28d1d628b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 30 Mar 2018 07:51:34 +0200 Subject: [PATCH 12/15] Xcode 9.3 artifact: IDEWorkspaceChecks.plist --- GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + From 2c3a62abbc10eb7240b8ce2e8b14abc6a1d17649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 30 Mar 2018 08:12:24 +0200 Subject: [PATCH 13/15] Update performance tests for Swift 4.1 --- GRDB.xcodeproj/project.pbxproj | 8 ++++---- Makefile | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 25c15e753..093beb624 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -946,8 +946,8 @@ 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = ""; }; 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = ""; }; 56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = ""; }; - 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.0.3/Realm.framework"; sourceTree = ""; }; - 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.0.3/RealmSwift.framework"; sourceTree = ""; }; + 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.1/Realm.framework"; sourceTree = ""; }; + 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.1/RealmSwift.framework"; sourceTree = ""; }; 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.xcconfig; sourceTree = ""; }; 56B9649C1DA51B4C0002DA19 /* FTS5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5.swift; sourceTree = ""; }; 56B964B01DA51D010002DA19 /* FTS5TokenizerDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5TokenizerDescriptor.swift; sourceTree = ""; }; @@ -2860,7 +2860,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.0.3", + "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/Info.plist; @@ -2883,7 +2883,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.0.3", + "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/Info.plist; diff --git a/Makefile b/Makefile index e8012b004..847fc35ac 100644 --- a/Makefile +++ b/Makefile @@ -254,10 +254,10 @@ test_performance: Realm FMDB SQLite.swift -scheme GRDBOSXPerformanceComparisonTests \ build-for-testing test-without-building -Realm: Tests/Performance/Realm/build/osx/swift-4.0.3/RealmSwift.framework +Realm: Tests/Performance/Realm/build/osx/swift-4.1/RealmSwift.framework # Makes sure the Tests/Performance/Realm submodule has been downloaded, and Realm framework has been built. -Tests/Performance/Realm/build/osx/swift-4.0.3/RealmSwift.framework: +Tests/Performance/Realm/build/osx/swift-4.1/RealmSwift.framework: $(GIT) submodule update --init --recursive Tests/Performance/Realm cd Tests/Performance/Realm && sh build.sh osx-swift @@ -306,10 +306,10 @@ ifdef JAZZY --author 'Gwendal Roué' \ --author_url https://github.com/groue \ --github_url https://github.com/groue/GRDB.swift \ - --github-file-prefix https://github.com/groue/GRDB.swift/tree/v2.9.0 \ - --module-version 2.9 \ + --github-file-prefix https://github.com/groue/GRDB.swift/tree/v2.10.0 \ + --module-version 2.10 \ --module GRDB \ - --root-url http://groue.github.io/GRDB.swift/docs/2.9/ \ + --root-url http://groue.github.io/GRDB.swift/docs/2.10/ \ --output Documentation/Reference \ --podspec GRDB.swift.podspec else From 17dfb0db9dafcab329f56289872ccfdc63ee6c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 30 Mar 2018 08:19:46 +0200 Subject: [PATCH 14/15] CHANGELOG --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df2fd449..eb75fe94a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ Release Notes ============= +## Next Version + +### New + +- Support for Swift 4.1 and Xcode 9.3 +- Added `Cursor.compactMap` ([SE-0187](https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md)) + +### Deprecated + +- `Cursor.flatMap` is deprecated. Use `compactMap` instead. + + ## 2.9.0 Released February 25, 2018 • [diff](https://github.com/groue/GRDB.swift/compare/v2.8.0...v2.9.0) From 91b574e15394927267b3cfb29840f56ebe15b8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 30 Mar 2018 08:25:07 +0200 Subject: [PATCH 15/15] v2.10.0 --- CHANGELOG.md | 4 ++- Documentation/CustomSQLiteBuilds.md | 2 +- GRDB.swift.podspec | 2 +- GRDBCipher.podspec | 2 +- README.md | 56 ++++++++++++++--------------- Support/Info.plist | 2 +- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb75fe94a..d6d28774e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ Release Notes ============= -## Next Version +## 2.10.0 + +Released March 30, 2018 • [diff](https://github.com/groue/GRDB.swift/compare/v2.9.0...v2.10.0) ### New diff --git a/Documentation/CustomSQLiteBuilds.md b/Documentation/CustomSQLiteBuilds.md index e43d8cdec..c9f525457 100644 --- a/Documentation/CustomSQLiteBuilds.md +++ b/Documentation/CustomSQLiteBuilds.md @@ -15,7 +15,7 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal ```sh cd [GRDB directory] - git checkout v2.9.0 + git checkout v2.10.0 git submodule update --init SQLiteCustom/src ```` diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index a72ea51e9..ec712b7d5 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '2.9.0' + s.version = '2.10.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A Swift application toolkit for SQLite databases.' diff --git a/GRDBCipher.podspec b/GRDBCipher.podspec index cba39bfca..d63ad4227 100644 --- a/GRDBCipher.podspec +++ b/GRDBCipher.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDBCipher' - s.version = '2.9.0' + s.version = '2.10.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A Swift application toolkit for SQLite databases.' diff --git a/README.md b/README.md index 8a627e387..850cbbcda 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ GRDB 2 [![Swift](https://img.shields.io/badge/swift-4-orange.svg?style=flat)](ht ### A toolkit for SQLite databases, with a focus on application development -**Latest release**: February 25, 2018 • version 2.9.0 • [CHANGELOG](CHANGELOG.md) +**Latest release**: March 30, 2018 • version 2.10.0 • [CHANGELOG](CHANGELOG.md) **Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4+ / Xcode 9+ | Swift version | GRDB version | | ------------- | ----------------------------------------------------------- | -| **Swift 4** | **v2.9.0** | +| **Swift 4+** | **v2.10.0** | | Swift 3.2 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | | Swift 3.1 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | | Swift 3 | [v1.0](https://github.com/groue/GRDB.swift/tree/v1.0) | @@ -197,7 +197,7 @@ Documentation **Reference** -- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/2.9/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) +- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/2.10/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) **Getting Started** @@ -265,7 +265,7 @@ The [Swift Package Manager](https://swift.org/package-manager/) automates the di ```swift let package = Package( dependencies: [ - .package(url: "https://github.com/groue/GRDB.swift.git", from: "2.9.0") + .package(url: "https://github.com/groue/GRDB.swift.git", from: "2.10.0") ] ) ``` @@ -282,7 +282,7 @@ If you decide to use Carthage despite this warning, and get any Carthage-related ## Manually -1. [Download](https://github.com/groue/GRDB.swift/releases/tag/v2.9.0) a copy of GRDB, or clone its repository and make sure you use the latest tagged version with the `git checkout v2.9.0` command. +1. [Download](https://github.com/groue/GRDB.swift/releases/tag/v2.10.0) a copy of GRDB, or clone its repository and make sure you use the latest tagged version with the `git checkout v2.10.0` command. 2. Embed the `GRDB.xcodeproj` project in your own project. @@ -379,7 +379,7 @@ let dbQueue = try DatabaseQueue( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) for more details. ## Database Pools @@ -462,7 +462,7 @@ let dbPool = try DatabasePool( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) for more details. Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information. @@ -675,7 +675,7 @@ Both arrays and cursors can iterate over database results. How do you choose one If you don't see, or don't care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate. -**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: +**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: ```swift // All URL hosts @@ -748,7 +748,7 @@ let rows = try Row.fetchAll(db, arguments: ["name": "Arthur"]) ``` -See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. +See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. Unlike row arrays that contain copies of the database rows, row cursors are close to the SQLite metal, and require a little care: @@ -1019,7 +1019,7 @@ GRDB ships with built-in support for the following value types: - Generally speaking, all types that adopt the [DatabaseValueConvertible](#custom-value-types) protocol. -Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let url: URL = ... @@ -1413,7 +1413,7 @@ try dbQueue.inDatabase { db in } ``` -The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). +The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). ```swift updateStatement.arguments = ["name": "Arthur", "score": 1000] @@ -1675,7 +1675,7 @@ row["consumed"] // "Hello" row["produced"] // nil ``` -Row adapters are values that adopt the [RowAdapter](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/RowAdapter.html) protocol. You can implement your own custom adapters ([**:fire: EXPERIMENTAL**](#what-are-experimental-features)), or use one of the four built-in adapters, described below. +Row adapters are values that adopt the [RowAdapter](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/RowAdapter.html) protocol. You can implement your own custom adapters ([**:fire: EXPERIMENTAL**](#what-are-experimental-features)), or use one of the four built-in adapters, described below. To see how row adapters can be used, see [Joined Queries Support](#joined-queries-support). @@ -1818,8 +1818,8 @@ Before jumping in the low-level wagon, here is the list of all SQLite APIs used - `sqlite3_aggregate_context`, `sqlite3_create_function_v2`, `sqlite3_result_blob`, `sqlite3_result_double`, `sqlite3_result_error`, `sqlite3_result_error_code`, `sqlite3_result_int64`, `sqlite3_result_null`, `sqlite3_result_text`, `sqlite3_user_data`, `sqlite3_value_blob`, `sqlite3_value_bytes`, `sqlite3_value_double`, `sqlite3_value_int64`, `sqlite3_value_text`, `sqlite3_value_type`: see [Custom SQL Functions and Aggregates](#custom-sql-functions-and-aggregates) - `sqlite3_backup_finish`, `sqlite3_backup_init`, `sqlite3_backup_step`: see [Backup](#backup) - `sqlite3_bind_blob`, `sqlite3_bind_double`, `sqlite3_bind_int64`, `sqlite3_bind_null`, `sqlite3_bind_parameter_count`, `sqlite3_bind_parameter_name`, `sqlite3_bind_text`, `sqlite3_clear_bindings`, `sqlite3_column_blob`, `sqlite3_column_bytes`, `sqlite3_column_count`, `sqlite3_column_double`, `sqlite3_column_int64`, `sqlite3_column_name`, `sqlite3_column_text`, `sqlite3_column_type`, `sqlite3_exec`, `sqlite3_finalize`, `sqlite3_prepare_v2`, `sqlite3_reset`, `sqlite3_step`: see [Executing Updates](#executing-updates), [Fetch Queries](#fetch-queries), [Prepared Statements](#prepared-statements), [Values](#values) -- `sqlite3_busy_handler`, `sqlite3_busy_timeout`: see [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) -- `sqlite3_changes`, `sqlite3_total_changes`: see [Database.changesCount and Database.totalChangesCount](http://groue.github.io/GRDB.swift/docs/2.9/Classes/Database.html) +- `sqlite3_busy_handler`, `sqlite3_busy_timeout`: see [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) +- `sqlite3_changes`, `sqlite3_total_changes`: see [Database.changesCount and Database.totalChangesCount](http://groue.github.io/GRDB.swift/docs/2.10/Classes/Database.html) - `sqlite3_close`, `sqlite3_close_v2`, `sqlite3_next_stmt`, `sqlite3_open_v2`: see [Database Connections](#database-connections) - `sqlite3_commit_hook`, `sqlite3_rollback_hook`, `sqlite3_update_hook`: see [TransactionObserver Protocol](#transactionobserver-protocol), [FetchedRecordsController](#fetchedrecordscontroller) - `sqlite3_config`: see [Error Log](#error-log) @@ -1830,9 +1830,9 @@ Before jumping in the low-level wagon, here is the list of all SQLite APIs used - `sqlite3_last_insert_rowid`: see [Executing Updates](#executing-updates) - `sqlite3_preupdate_count`, `sqlite3_preupdate_depth`, `sqlite3_preupdate_hook`, `sqlite3_preupdate_new`, `sqlite3_preupdate_old`: see [Support for SQLite Pre-Update Hooks](#support-for-sqlite-pre-update-hooks) - `sqlite3_set_authorizer`: **reserved by GRDB** -- `sqlite3_sql`: see [Statement.sql](http://groue.github.io/GRDB.swift/docs/2.9/Classes/Statement.html) -- `sqlite3_trace`: see [Configuration.trace](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) -- `sqlite3_wal_checkpoint_v2`: see [DatabasePool.checkpoint](http://groue.github.io/GRDB.swift/docs/2.9/Classes/DatabasePool.html) +- `sqlite3_sql`: see [Statement.sql](http://groue.github.io/GRDB.swift/docs/2.10/Classes/Statement.html) +- `sqlite3_trace`: see [Configuration.trace](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) +- `sqlite3_wal_checkpoint_v2`: see [DatabasePool.checkpoint](http://groue.github.io/GRDB.swift/docs/2.10/Classes/DatabasePool.html) Records @@ -2117,7 +2117,7 @@ try Place.fetchAll(db, "SELECT ...", arguments:...) // [Place] try Place.fetchOne(db, "SELECT ...", arguments:...) // Place? ``` -See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html) for more information about the query arguments. +See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html) for more information about the query arguments. ## TableMapping Protocol @@ -3243,7 +3243,7 @@ Player // SELECT * FROM players ``` -Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift // SELECT DATE(creationDate), COUNT(*) FROM players WHERE name = 'Arthur' GROUP BY date(creationDate) @@ -3750,9 +3750,9 @@ try request.fetchOne(db) // Player? **To build custom requests**, you can create your own type that adopts the protocols, or derive requests from other requests, or use one of the built-in concrete types: -- [SQLRequest](http://groue.github.io/GRDB.swift/docs/2.9/Structs/SQLRequest.html): a Request built from raw SQL -- [AnyRequest](http://groue.github.io/GRDB.swift/docs/2.9/Structs/AnyRequest.html): a type-erased Request -- [AnyTypedRequest](http://groue.github.io/GRDB.swift/docs/2.9/Structs/AnyTypedRequest.html): a type-erased TypedRequest +- [SQLRequest](http://groue.github.io/GRDB.swift/docs/2.10/Structs/SQLRequest.html): a Request built from raw SQL +- [AnyRequest](http://groue.github.io/GRDB.swift/docs/2.10/Structs/AnyRequest.html): a type-erased Request +- [AnyTypedRequest](http://groue.github.io/GRDB.swift/docs/2.10/Structs/AnyTypedRequest.html): a type-erased TypedRequest Use the `asRequest(of:)` method to define the type fetched by the request: @@ -4148,7 +4148,7 @@ let pattern = FTS3Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS3Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS3Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +FTS3Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, @@ -4363,7 +4363,7 @@ let pattern = FTS5Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS5Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS5Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +FTS5Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, @@ -5600,7 +5600,7 @@ Alternatively, perform a manual installation of GRDB and SQLCipher: ```sh cd [GRDB directory] - git checkout v2.9.0 + git checkout v2.10.0 git submodule update --init SQLCipher/src ``` @@ -5707,7 +5707,7 @@ DROP TABLE students; --' WHERE id = 1 ``` -To avoid those problems, **never embed raw values in your SQL queries**. The only correct technique is to provide [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html) to your SQL queries: +To avoid those problems, **never embed raw values in your SQL queries**. The only correct technique is to provide [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html) to your SQL queries: ```swift // Good @@ -6369,7 +6369,7 @@ try snapshot2.read { db in ### DatabaseWriter and DatabaseReader Protocols -Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. +Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. These protocols provide a unified API that lets you write safe concurrent code that targets all three concurrency modes. @@ -6463,7 +6463,7 @@ If you absolutely need multiple connections, then: - Read about [isolation in SQLite](https://www.sqlite.org/isolation.html) - Learn about [locks and transactions](https://www.sqlite.org/lang_transaction.html) - Become a master of the [WAL mode](https://www.sqlite.org/wal.html) -- Prepare to setup a [busy handler](https://www.sqlite.org/c3ref/busy_handler.html) with [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) +- Prepare to setup a [busy handler](https://www.sqlite.org/c3ref/busy_handler.html) with [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) - [Ask questions](https://github.com/groue/GRDB.swift/issues) diff --git a/Support/Info.plist b/Support/Info.plist index 5d9392735..19f6efcfe 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.9.0 + 2.10.0 CFBundleSignature ???? CFBundleVersion