From f40ca4da2f02204fdc5e3d317014062fac55326a Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 12 Apr 2018 18:04:41 +0200 Subject: [PATCH 1/5] Fix Swift 4.1 warnings --- .travis.yml | 2 +- SQLite.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/xcschemes/SQLite Mac.xcscheme | 4 +--- .../xcshareddata/xcschemes/SQLite iOS.xcscheme | 4 +--- .../xcschemes/SQLite tvOS.xcscheme | 4 +--- .../xcschemes/SQLite watchOS.xcscheme | 2 +- Sources/SQLite/Typed/Coding.swift | 2 +- Sources/SQLite/Typed/CoreFunctions.swift | 2 +- Sources/SQLite/Typed/Query.swift | 8 ++++---- Sources/SQLite/Typed/Schema.swift | 18 +++++++++--------- Tests/SQLiteTests/BlobTests.swift | 2 +- Tests/SQLiteTests/ConnectionTests.swift | 2 +- Tests/SQLiteTests/FTS4Tests.swift | 2 +- 13 files changed, 28 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f17b26f..41389849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c rvm: 2.3 -osx_image: xcode9 +osx_image: xcode9.3 env: global: - IOS_SIMULATOR="iPhone 6s" diff --git a/SQLite.xcodeproj/project.pbxproj b/SQLite.xcodeproj/project.pbxproj index df603862..2015b8ff 100644 --- a/SQLite.xcodeproj/project.pbxproj +++ b/SQLite.xcodeproj/project.pbxproj @@ -680,7 +680,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; TargetAttributes = { 03A65E591C6BB0F50062603F = { CreatedOnToolsVersion = 7.2; @@ -1148,12 +1148,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; @@ -1206,12 +1208,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; diff --git a/SQLite.xcodeproj/xcshareddata/xcschemes/SQLite Mac.xcscheme b/SQLite.xcodeproj/xcshareddata/xcschemes/SQLite Mac.xcscheme index f1fa216c..2691862e 100644 --- a/SQLite.xcodeproj/xcshareddata/xcschemes/SQLite Mac.xcscheme +++ b/SQLite.xcodeproj/xcshareddata/xcschemes/SQLite Mac.xcscheme @@ -1,6 +1,6 @@ Bool { diff --git a/Sources/SQLite/Typed/CoreFunctions.swift b/Sources/SQLite/Typed/CoreFunctions.swift index 1afe4e87..d7995b95 100644 --- a/Sources/SQLite/Typed/CoreFunctions.swift +++ b/Sources/SQLite/Typed/CoreFunctions.swift @@ -637,7 +637,7 @@ extension ExpressionType where UnderlyingType == String? { } -extension Collection where Iterator.Element : Value, IndexDistance == Int { +extension Collection where Iterator.Element : Value { /// Builds a copy of the expression prepended with an `IN` check against the /// collection. diff --git a/Sources/SQLite/Typed/Query.swift b/Sources/SQLite/Typed/Query.swift index 1d04b797..f6ef6df8 100644 --- a/Sources/SQLite/Typed/Query.swift +++ b/Sources/SQLite/Typed/Query.swift @@ -647,7 +647,7 @@ extension QueryType { whereClause ] - return Insert(" ".join(clauses.flatMap { $0 }).expression) + return Insert(" ".join(clauses.compactMap { $0 }).expression) } /// Runs an `INSERT` statement against the query with `DEFAULT VALUES`. @@ -690,7 +690,7 @@ extension QueryType { limitOffsetClause ] - return Update(" ".join(clauses.flatMap { $0 }).expression) + return Update(" ".join(clauses.compactMap { $0 }).expression) } // MARK: DELETE @@ -704,7 +704,7 @@ extension QueryType { limitOffsetClause ] - return Delete(" ".join(clauses.flatMap { $0 }).expression) + return Delete(" ".join(clauses.compactMap { $0 }).expression) } // MARK: EXISTS @@ -789,7 +789,7 @@ extension QueryType { limitOffsetClause ] - return " ".join(clauses.flatMap { $0 }).expression + return " ".join(clauses.compactMap { $0 }).expression } } diff --git a/Sources/SQLite/Typed/Schema.swift b/Sources/SQLite/Typed/Schema.swift index 60b7be8a..62c90702 100644 --- a/Sources/SQLite/Typed/Schema.swift +++ b/Sources/SQLite/Typed/Schema.swift @@ -47,7 +47,7 @@ extension Table { withoutRowid ? Expression(literal: "WITHOUT ROWID") : nil ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } public func create(_ query: QueryType, temporary: Bool = false, ifNotExists: Bool = false) -> String { @@ -57,7 +57,7 @@ extension Table { query ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } // MARK: - ALTER TABLE … ADD COLUMN @@ -135,7 +135,7 @@ extension Table { "".wrap(columns) as Expression ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } // MARK: - DROP INDEX @@ -174,7 +174,7 @@ extension View { query ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } // MARK: - DROP VIEW @@ -196,7 +196,7 @@ extension VirtualTable { using ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } // MARK: - ALTER TABLE … RENAME TO @@ -405,7 +405,7 @@ public final class TableBuilder { delete.map { Expression(literal: "ON DELETE \($0.rawValue)") } ] - definitions.append(" ".join(clauses.flatMap { $0 })) + definitions.append(" ".join(clauses.compactMap { $0 })) } } @@ -456,7 +456,7 @@ private extension QueryType { name ] - return " ".join(clauses.flatMap { $0 }) + return " ".join(clauses.compactMap { $0 }) } func rename(to: Self) -> String { @@ -475,7 +475,7 @@ private extension QueryType { name ] - return " ".join(clauses.flatMap { $0 }).asSQL() + return " ".join(clauses.compactMap { $0 }).asSQL() } } @@ -493,7 +493,7 @@ private func definition(_ column: Expressible, _ datatype: String, _ primaryKey: collate.map { " ".join([Expression(literal: "COLLATE"), $0]) } ] - return " ".join(clauses.flatMap { $0 }) + return " ".join(clauses.compactMap { $0 }) } private func reference(_ primary: (QueryType, Expressible)) -> Expressible { diff --git a/Tests/SQLiteTests/BlobTests.swift b/Tests/SQLiteTests/BlobTests.swift index fbcca9bc..817205d6 100644 --- a/Tests/SQLiteTests/BlobTests.swift +++ b/Tests/SQLiteTests/BlobTests.swift @@ -16,7 +16,7 @@ class BlobTests : XCTestCase { func test_init_unsafeRawPointer() { let pointer = UnsafeMutablePointer.allocate(capacity: 3) - pointer.initialize(to: 42, count: 3) + pointer.initialize(repeating: 42, count: 3) let blob = Blob(bytes: pointer, length: 3) XCTAssertEqual(blob.bytes, [42, 42, 42]) } diff --git a/Tests/SQLiteTests/ConnectionTests.swift b/Tests/SQLiteTests/ConnectionTests.swift index 7bb86e41..7fc26110 100644 --- a/Tests/SQLiteTests/ConnectionTests.swift +++ b/Tests/SQLiteTests/ConnectionTests.swift @@ -157,7 +157,7 @@ class ConnectionTests : SQLiteTestCase { func test_transaction_rollsBackTransactionsIfCommitsFail() { let sqliteVersion = String(describing: try! db.scalar("SELECT sqlite_version()")!) - .split(separator: ".").flatMap { Int($0) } + .split(separator: ".").compactMap { Int($0) } // PRAGMA defer_foreign_keys only supported in SQLite >= 3.8.0 guard sqliteVersion[0] == 3 && sqliteVersion[1] >= 8 else { NSLog("skipping test for SQLite version \(sqliteVersion)") diff --git a/Tests/SQLiteTests/FTS4Tests.swift b/Tests/SQLiteTests/FTS4Tests.swift index 4373bf8b..79f0a8e2 100644 --- a/Tests/SQLiteTests/FTS4Tests.swift +++ b/Tests/SQLiteTests/FTS4Tests.swift @@ -184,7 +184,7 @@ class FTS4IntegrationTests : SQLiteTestCase { let locale = CFLocaleCopyCurrent() let tokenizerName = "tokenizer" - let tokenizer = CFStringTokenizerCreate(nil, "" as CFString!, CFRangeMake(0, 0), UInt(kCFStringTokenizerUnitWord), locale) + let tokenizer = CFStringTokenizerCreate(nil, "" as CFString, CFRangeMake(0, 0), UInt(kCFStringTokenizerUnitWord), locale) try! db.registerTokenizer(tokenizerName) { string in CFStringTokenizerSetString(tokenizer, string as CFString, CFRangeMake(0, CFStringGetLength(string as CFString))) if CFStringTokenizerAdvanceToNextToken(tokenizer).isEmpty { From 1ed747ec930889de2b6e79451a8c37eea3109326 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 12 Apr 2018 18:43:32 +0200 Subject: [PATCH 2/5] Fix iOS version --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41389849..f278301d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ osx_image: xcode9.3 env: global: - IOS_SIMULATOR="iPhone 6s" - - IOS_VERSION="11.0" + - IOS_VERSION="11.3" matrix: include: - env: BUILD_SCHEME="SQLite iOS" diff --git a/Makefile b/Makefile index ebd38494..cd4afb8d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BUILD_TOOL = xcodebuild BUILD_SCHEME = SQLite Mac IOS_SIMULATOR = iPhone 6s -IOS_VERSION = 11.0 +IOS_VERSION = 11.3 ifeq ($(BUILD_SCHEME),SQLite iOS) BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)" else From be9fc789c3772edaef83000deda20ab777f607f7 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Thu, 12 Apr 2018 23:10:41 +0200 Subject: [PATCH 3/5] Update bundle --- Tests/CocoaPods/Gemfile | 2 +- Tests/CocoaPods/Gemfile.lock | 54 +++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/Tests/CocoaPods/Gemfile b/Tests/CocoaPods/Gemfile index 04f0155a..3b9d6ba5 100644 --- a/Tests/CocoaPods/Gemfile +++ b/Tests/CocoaPods/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.3.1' +gem 'cocoapods', '~> 1.5.0' gem 'minitest' diff --git a/Tests/CocoaPods/Gemfile.lock b/Tests/CocoaPods/Gemfile.lock index 47a2db58..de03030a 100644 --- a/Tests/CocoaPods/Gemfile.lock +++ b/Tests/CocoaPods/Gemfile.lock @@ -1,73 +1,77 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.5) - activesupport (4.2.9) + CFPropertyList (3.0.0) + activesupport (4.2.10) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + atomos (0.1.2) claide (1.0.2) - cocoapods (1.3.1) + cocoapods (1.5.0) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.3.1) - cocoapods-deintegrate (>= 1.0.1, < 2.0) - cocoapods-downloader (>= 1.1.3, < 2.0) + cocoapods-core (= 1.5.0) + cocoapods-deintegrate (>= 1.0.2, < 2.0) + cocoapods-downloader (>= 1.2.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.2.0, < 2.0) + cocoapods-trunk (>= 1.3.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) fourflusher (~> 2.0.1) gh_inspector (~> 1.0) - molinillo (~> 0.5.7) + molinillo (~> 0.6.5) nap (~> 1.0) ruby-macho (~> 1.1) - xcodeproj (>= 1.5.1, < 2.0) - cocoapods-core (1.3.1) + xcodeproj (>= 1.5.7, < 2.0) + cocoapods-core (1.5.0) activesupport (>= 4.0.2, < 6) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-deintegrate (1.0.1) - cocoapods-downloader (1.1.3) + cocoapods-deintegrate (1.0.2) + cocoapods-downloader (1.2.0) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.2.0) + cocoapods-trunk (1.3.0) nap (>= 0.8, < 2.0) - netrc (= 0.7.8) + netrc (~> 0.11) cocoapods-try (1.1.0) colored2 (3.1.2) + concurrent-ruby (1.0.5) escape (0.0.4) fourflusher (2.0.1) fuzzy_match (2.0.4) - gh_inspector (1.0.3) - i18n (0.8.6) + gh_inspector (1.1.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) minitest (5.10.1) - molinillo (0.5.7) - nanaimo (0.2.3) + molinillo (0.6.5) + nanaimo (0.2.5) nap (1.1.0) - netrc (0.7.8) + netrc (0.11.0) ruby-macho (1.1.0) thread_safe (0.3.6) - tzinfo (1.2.3) + tzinfo (1.2.5) thread_safe (~> 0.1) - xcodeproj (1.5.1) - CFPropertyList (~> 2.3.3) + xcodeproj (1.5.7) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.2) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.2.3) + nanaimo (~> 0.2.4) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.3.1) + cocoapods (~> 1.5.0) minitest BUNDLED WITH - 1.13.6 + 1.16.1 From afd58d3ba205c4b0065528f5c1180e0685ee1388 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Fri, 13 Apr 2018 01:21:48 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Don=E2=80=99t=20run=20iOS=20tests=20on=20ol?= =?UTF-8?q?dest=20sim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “Early unexpected exit, operation never finished bootstrapping” --- Tests/CocoaPods/integration_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Tests/CocoaPods/integration_test.rb b/Tests/CocoaPods/integration_test.rb index 9792b570..4bec8d40 100755 --- a/Tests/CocoaPods/integration_test.rb +++ b/Tests/CocoaPods/integration_test.rb @@ -39,5 +39,32 @@ def test_pod # https://github.com/CocoaPods/CocoaPods/issues/7009 super unless consumer.platform_name == :watchos end + + def xcodebuild(action, scheme, configuration) + require 'fourflusher' + command = %W(clean #{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration}) + case consumer.platform_name + when :osx, :macos + command += %w(CODE_SIGN_IDENTITY=) + when :ios + command += %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator) + command += Fourflusher::SimControl.new.destination(nil, 'iOS', deployment_target) + when :watchos + command += %w(CODE_SIGN_IDENTITY=- -sdk watchsimulator) + command += Fourflusher::SimControl.new.destination(:oldest, 'watchOS', deployment_target) + when :tvos + command += %w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator) + command += Fourflusher::SimControl.new.destination(:oldest, 'tvOS', deployment_target) + end + + begin + _xcodebuild(command, true) + rescue => e + message = 'Returned an unsuccessful exit code.' + message += ' You can use `--verbose` for more information.' unless config.verbose? + error('xcodebuild', message) + e.message + end + end end end From a1d478eb4325a8c980b99afdfc8e4a29dab0c3e0 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Fri, 13 Apr 2018 23:05:19 +0200 Subject: [PATCH 5/5] Exclude test on iOS/tvOS 9.x --- SQLite.xcodeproj/project.pbxproj | 4 ++-- Tests/SQLiteTests/ConnectionTests.swift | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SQLite.xcodeproj/project.pbxproj b/SQLite.xcodeproj/project.pbxproj index 2015b8ff..75b38526 100644 --- a/SQLite.xcodeproj/project.pbxproj +++ b/SQLite.xcodeproj/project.pbxproj @@ -1063,7 +1063,7 @@ 03A65E6D1C6BB0F60062603F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - INFOPLIST_FILE = Tests/SQLite/Info.plist; + INFOPLIST_FILE = Tests/SQLiteTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1077,7 +1077,7 @@ 03A65E6E1C6BB0F60062603F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - INFOPLIST_FILE = Tests/SQLite/Info.plist; + INFOPLIST_FILE = Tests/SQLiteTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Tests/SQLiteTests/ConnectionTests.swift b/Tests/SQLiteTests/ConnectionTests.swift index 7fc26110..9480e3bb 100644 --- a/Tests/SQLiteTests/ConnectionTests.swift +++ b/Tests/SQLiteTests/ConnectionTests.swift @@ -384,6 +384,9 @@ class ConnectionTests : SQLiteTestCase { } func test_concurrent_access_single_connection() { + // test can fail on iOS/tvOS 9.x: SQLite compile-time differences? + guard #available(iOS 10.0, OSX 10.10, tvOS 10.0, watchOS 2.2, *) else { return } + let conn = try! Connection("\(NSTemporaryDirectory())/\(UUID().uuidString)") try! conn.execute("DROP TABLE IF EXISTS test; CREATE TABLE test(value);") try! conn.run("INSERT INTO test(value) VALUES(?)", 0)