Skip to content

Commit cf4183f

Browse files
committed
Swift 4.2, Xcode 10.1
- fix tests running agains SQLCipher 4.x
1 parent d13baed commit cf4183f

16 files changed

+83
-73
lines changed

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1
1+
4.2

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
language: objective-c
22
rvm: 2.3
3-
osx_image: xcode9.3
3+
# https://docs.travis-ci.com/user/reference/osx
4+
osx_image: xcode10.1
45
env:
56
global:
67
- IOS_SIMULATOR="iPhone 6s"
7-
- IOS_VERSION="11.3"
8+
- IOS_VERSION="12.1"
89
matrix:
910
include:
1011
- env: BUILD_SCHEME="SQLite iOS"

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.11.6 (xxx), [diff][diff-0.11.6]
2+
========================================
3+
4+
* Swift 4.2, SQLCipher 4.x ([#866][])
5+
16
0.11.5 (04-14-2018), [diff][diff-0.11.5]
27
========================================
38

@@ -57,6 +62,7 @@
5762
[diff-0.11.3]: https://github.com/stephencelis/SQLite.swift/compare/0.11.2...0.11.3
5863
[diff-0.11.4]: https://github.com/stephencelis/SQLite.swift/compare/0.11.3...0.11.4
5964
[diff-0.11.5]: https://github.com/stephencelis/SQLite.swift/compare/0.11.4...0.11.5
65+
[diff-0.11.6]: https://github.com/stephencelis/SQLite.swift/compare/0.11.5...0.11.6
6066

6167
[#142]: https://github.com/stephencelis/SQLite.swift/issues/142
6268
[#315]: https://github.com/stephencelis/SQLite.swift/issues/315
@@ -88,3 +94,4 @@
8894
[#733]: https://github.com/stephencelis/SQLite.swift/pull/733
8995
[#726]: https://github.com/stephencelis/SQLite.swift/pull/726
9096
[#797]: https://github.com/stephencelis/SQLite.swift/pull/797
97+
[#866]: https://github.com/stephencelis/SQLite.swift/pull/866

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BUILD_TOOL = xcodebuild
22
BUILD_SCHEME = SQLite Mac
33
IOS_SIMULATOR = iPhone 6s
4-
IOS_VERSION = 11.3
4+
IOS_VERSION = 12.1
55
ifeq ($(BUILD_SCHEME),SQLite iOS)
66
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)"
77
else

SQLite.swift.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
2121
s.watchos.deployment_target = "2.2"
2222
s.default_subspec = 'standard'
2323
s.pod_target_xcconfig = {
24-
'SWIFT_VERSION' => '4.1',
24+
'SWIFT_VERSION' => '4.2',
2525
}
2626

2727
s.subspec 'standard' do |ss|

SQLite.xcodeproj/project.pbxproj

+14-14
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@
10331033
SDKROOT = appletvos;
10341034
SKIP_INSTALL = YES;
10351035
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1036-
SWIFT_VERSION = 4.0;
1036+
SWIFT_VERSION = 4.2;
10371037
TVOS_DEPLOYMENT_TARGET = 9.1;
10381038
};
10391039
name = Debug;
@@ -1055,7 +1055,7 @@
10551055
SDKROOT = appletvos;
10561056
SKIP_INSTALL = YES;
10571057
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1058-
SWIFT_VERSION = 4.0;
1058+
SWIFT_VERSION = 4.2;
10591059
TVOS_DEPLOYMENT_TARGET = 9.1;
10601060
};
10611061
name = Release;
@@ -1069,7 +1069,7 @@
10691069
PRODUCT_NAME = "$(TARGET_NAME)";
10701070
SDKROOT = appletvos;
10711071
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1072-
SWIFT_VERSION = 4.0;
1072+
SWIFT_VERSION = 4.2;
10731073
TVOS_DEPLOYMENT_TARGET = 9.1;
10741074
};
10751075
name = Debug;
@@ -1083,7 +1083,7 @@
10831083
PRODUCT_NAME = "$(TARGET_NAME)";
10841084
SDKROOT = appletvos;
10851085
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1086-
SWIFT_VERSION = 4.0;
1086+
SWIFT_VERSION = 4.2;
10871087
TVOS_DEPLOYMENT_TARGET = 9.1;
10881088
};
10891089
name = Release;
@@ -1106,7 +1106,7 @@
11061106
SDKROOT = watchos;
11071107
SKIP_INSTALL = YES;
11081108
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1109-
SWIFT_VERSION = 4.0;
1109+
SWIFT_VERSION = 4.2;
11101110
TARGETED_DEVICE_FAMILY = 4;
11111111
WATCHOS_DEPLOYMENT_TARGET = 2.2;
11121112
};
@@ -1130,7 +1130,7 @@
11301130
SDKROOT = watchos;
11311131
SKIP_INSTALL = YES;
11321132
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1133-
SWIFT_VERSION = 4.0;
1133+
SWIFT_VERSION = 4.2;
11341134
TARGETED_DEVICE_FAMILY = 4;
11351135
WATCHOS_DEPLOYMENT_TARGET = 2.2;
11361136
};
@@ -1269,7 +1269,7 @@
12691269
SKIP_INSTALL = YES;
12701270
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
12711271
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1272-
SWIFT_VERSION = 4.0;
1272+
SWIFT_VERSION = 4.2;
12731273
};
12741274
name = Debug;
12751275
};
@@ -1291,7 +1291,7 @@
12911291
PRODUCT_NAME = SQLite;
12921292
SKIP_INSTALL = YES;
12931293
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1294-
SWIFT_VERSION = 4.0;
1294+
SWIFT_VERSION = 4.2;
12951295
};
12961296
name = Release;
12971297
};
@@ -1304,7 +1304,7 @@
13041304
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
13051305
PRODUCT_NAME = "$(TARGET_NAME)";
13061306
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1307-
SWIFT_VERSION = 4.0;
1307+
SWIFT_VERSION = 4.2;
13081308
};
13091309
name = Debug;
13101310
};
@@ -1317,7 +1317,7 @@
13171317
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
13181318
PRODUCT_NAME = "$(TARGET_NAME)";
13191319
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1320-
SWIFT_VERSION = 4.0;
1320+
SWIFT_VERSION = 4.2;
13211321
};
13221322
name = Release;
13231323
};
@@ -1342,7 +1342,7 @@
13421342
SKIP_INSTALL = YES;
13431343
SWIFT_INCLUDE_PATHS = "";
13441344
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1345-
SWIFT_VERSION = 4.0;
1345+
SWIFT_VERSION = 4.2;
13461346
};
13471347
name = Debug;
13481348
};
@@ -1367,7 +1367,7 @@
13671367
SKIP_INSTALL = YES;
13681368
SWIFT_INCLUDE_PATHS = "";
13691369
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1370-
SWIFT_VERSION = 4.0;
1370+
SWIFT_VERSION = 4.2;
13711371
};
13721372
name = Release;
13731373
};
@@ -1383,7 +1383,7 @@
13831383
PRODUCT_NAME = "$(TARGET_NAME)";
13841384
SDKROOT = macosx;
13851385
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1386-
SWIFT_VERSION = 4.0;
1386+
SWIFT_VERSION = 4.2;
13871387
};
13881388
name = Debug;
13891389
};
@@ -1399,7 +1399,7 @@
13991399
PRODUCT_NAME = "$(TARGET_NAME)";
14001400
SDKROOT = macosx;
14011401
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1402-
SWIFT_VERSION = 4.0;
1402+
SWIFT_VERSION = 4.2;
14031403
};
14041404
name = Release;
14051405
};

Sources/SQLite/Extensions/Cipher.swift

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import SQLCipher
66
/// @see [sqlcipher api](https://www.zetetic.net/sqlcipher/sqlcipher-api/)
77
extension Connection {
88

9+
/// - Returns: the SQLCipher version
10+
public var cipherVersion: String? {
11+
return (try? scalar("PRAGMA cipher_version")) as? String
12+
}
13+
914
/// Specify the key for an encrypted database. This routine should be
1015
/// called right after sqlite3_open().
1116
///

Sources/SQLiteObjc/include/SQLite-Bridging.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
//
2424

2525
@import Foundation;
26-
27-
#import "sqlite3.h"
26+
@import SQLite3;
2827

2928
NS_ASSUME_NONNULL_BEGIN
3029
typedef NSString * _Nullable (^_SQLiteTokenizerNextCallback)(const char *input, int *inputOffset, int *inputLength);

Tests/CocoaPods/Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
source 'https://rubygems.org'
22

3-
gem 'cocoapods', '~> 1.5.0'
3+
gem 'cocoapods', '~> 1.6.0beta2'
44
gem 'minitest'

Tests/CocoaPods/Gemfile.lock

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,76 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
CFPropertyList (3.0.0)
5-
activesupport (4.2.10)
5+
activesupport (4.2.11)
66
i18n (~> 0.7)
77
minitest (~> 5.1)
88
thread_safe (~> 0.3, >= 0.3.4)
99
tzinfo (~> 1.1)
10-
atomos (0.1.2)
10+
atomos (0.1.3)
1111
claide (1.0.2)
12-
cocoapods (1.5.0)
12+
cocoapods (1.6.0.beta.2)
1313
activesupport (>= 4.0.2, < 5)
1414
claide (>= 1.0.2, < 2.0)
15-
cocoapods-core (= 1.5.0)
15+
cocoapods-core (= 1.6.0.beta.2)
1616
cocoapods-deintegrate (>= 1.0.2, < 2.0)
17-
cocoapods-downloader (>= 1.2.0, < 2.0)
17+
cocoapods-downloader (>= 1.2.2, < 2.0)
1818
cocoapods-plugins (>= 1.0.0, < 2.0)
1919
cocoapods-search (>= 1.0.0, < 2.0)
2020
cocoapods-stats (>= 1.0.0, < 2.0)
21-
cocoapods-trunk (>= 1.3.0, < 2.0)
21+
cocoapods-trunk (>= 1.3.1, < 2.0)
2222
cocoapods-try (>= 1.1.0, < 2.0)
2323
colored2 (~> 3.1)
2424
escape (~> 0.0.4)
2525
fourflusher (~> 2.0.1)
2626
gh_inspector (~> 1.0)
27-
molinillo (~> 0.6.5)
27+
molinillo (~> 0.6.6)
2828
nap (~> 1.0)
29-
ruby-macho (~> 1.1)
30-
xcodeproj (>= 1.5.7, < 2.0)
31-
cocoapods-core (1.5.0)
29+
ruby-macho (~> 1.3, >= 1.3.1)
30+
xcodeproj (>= 1.7.0, < 2.0)
31+
cocoapods-core (1.6.0.beta.2)
3232
activesupport (>= 4.0.2, < 6)
3333
fuzzy_match (~> 2.0.4)
3434
nap (~> 1.0)
3535
cocoapods-deintegrate (1.0.2)
36-
cocoapods-downloader (1.2.0)
36+
cocoapods-downloader (1.2.2)
3737
cocoapods-plugins (1.0.0)
3838
nap
3939
cocoapods-search (1.0.0)
4040
cocoapods-stats (1.0.0)
41-
cocoapods-trunk (1.3.0)
41+
cocoapods-trunk (1.3.1)
4242
nap (>= 0.8, < 2.0)
4343
netrc (~> 0.11)
4444
cocoapods-try (1.1.0)
4545
colored2 (3.1.2)
46-
concurrent-ruby (1.0.5)
46+
concurrent-ruby (1.1.4)
4747
escape (0.0.4)
4848
fourflusher (2.0.1)
4949
fuzzy_match (2.0.4)
5050
gh_inspector (1.1.3)
5151
i18n (0.9.5)
5252
concurrent-ruby (~> 1.0)
53-
minitest (5.10.1)
54-
molinillo (0.6.5)
55-
nanaimo (0.2.5)
53+
minitest (5.11.3)
54+
molinillo (0.6.6)
55+
nanaimo (0.2.6)
5656
nap (1.1.0)
5757
netrc (0.11.0)
58-
ruby-macho (1.1.0)
58+
ruby-macho (1.3.1)
5959
thread_safe (0.3.6)
6060
tzinfo (1.2.5)
6161
thread_safe (~> 0.1)
62-
xcodeproj (1.5.7)
62+
xcodeproj (1.7.0)
6363
CFPropertyList (>= 2.3.3, < 4.0)
64-
atomos (~> 0.1.2)
64+
atomos (~> 0.1.3)
6565
claide (>= 1.0.2, < 2.0)
6666
colored2 (~> 3.1)
67-
nanaimo (~> 0.2.4)
67+
nanaimo (~> 0.2.6)
6868

6969
PLATFORMS
7070
ruby
7171

7272
DEPENDENCIES
73-
cocoapods (~> 1.5.0)
73+
cocoapods (~> 1.6.0beta2)
7474
minitest
7575

7676
BUNDLED WITH
77-
1.16.1
77+
1.17.1

Tests/CocoaPods/integration_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_pod
4242

4343
def xcodebuild(action, scheme, configuration)
4444
require 'fourflusher'
45-
command = %W(clean #{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration})
45+
command = %W(#{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration})
4646
case consumer.platform_name
4747
when :osx, :macos
4848
command += %w(CODE_SIGN_IDENTITY=)

Tests/SQLiteTests/CipherTests.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ class CipherTests: XCTestCase {
7373
}
7474

7575
func test_open_db_encrypted_with_sqlcipher() {
76-
// $ sqlcipher SQLiteTests/fixtures/encrypted.sqlite
76+
// $ sqlcipher Tests/SQLiteTests/fixtures/encrypted-[version].x.sqlite
7777
// sqlite> pragma key = 'sqlcipher-test';
7878
// sqlite> CREATE TABLE foo (bar TEXT);
7979
// sqlite> INSERT INTO foo (bar) VALUES ('world');
80-
let encryptedFile = fixture("encrypted", withExtension: "sqlite")
80+
guard let cipherVersion:String = db1.cipherVersion,
81+
cipherVersion.starts(with: "3.") || cipherVersion.starts(with: "4.")
82+
else { return }
83+
84+
let encryptedFile = cipherVersion.starts(with: "3.") ?
85+
fixture("encrypted-3.x", withExtension: "sqlite") :
86+
fixture("encrypted-4.x", withExtension: "sqlite")
8187

8288
try! FileManager.default.setAttributes([FileAttributeKey.immutable : 1], ofItemAtPath: encryptedFile)
8389
XCTAssertFalse(FileManager.default.isWritableFile(atPath: encryptedFile))

Tests/SQLiteTests/ConnectionTests.swift

+18-17
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,23 @@ class ConnectionTests : SQLiteTestCase {
369369
}
370370

371371
func test_interrupt_interruptsLongRunningQuery() {
372-
try! InsertUsers("abcdefghijklmnopqrstuvwxyz".map { String($0) })
372+
let semaphore = DispatchSemaphore(value: 0)
373373
db.createFunction("sleep") { args in
374-
usleep(UInt32((args[0] as? Double ?? Double(args[0] as? Int64 ?? 1)) * 1_000_000))
374+
DispatchQueue.global(qos: .background).async {
375+
self.db.interrupt()
376+
semaphore.signal()
377+
}
378+
semaphore.wait()
375379
return nil
376380
}
377-
378-
let stmt = try! db.prepare("SELECT *, sleep(?) FROM users", 0.1)
379-
try! stmt.run()
380-
381-
let deadline = DispatchTime.now() + 0.01
382-
_ = DispatchQueue(label: "queue", qos: .background).asyncAfter(deadline: deadline, execute: db.interrupt)
383-
AssertThrows(try stmt.run())
381+
let stmt = try! db.prepare("SELECT sleep()")
382+
XCTAssertThrowsError(try stmt.run()) { error in
383+
if case Result.error(_, let code, _) = error {
384+
XCTAssertEqual(code, SQLITE_INTERRUPT)
385+
} else {
386+
XCTFail("unexpected error: \(error)")
387+
}
388+
}
384389
}
385390

386391
func test_concurrent_access_single_connection() {
@@ -391,21 +396,17 @@ class ConnectionTests : SQLiteTestCase {
391396
try! conn.execute("DROP TABLE IF EXISTS test; CREATE TABLE test(value);")
392397
try! conn.run("INSERT INTO test(value) VALUES(?)", 0)
393398
let queue = DispatchQueue(label: "Readers", attributes: [.concurrent])
399+
394400
let nReaders = 5
395-
var reads = Array(repeating: 0, count: nReaders)
396-
var finished = false
401+
let semaphores = Array(repeating: DispatchSemaphore(value: 100), count: nReaders)
397402
for index in 0..<nReaders {
398403
queue.async {
399-
while !finished {
404+
while semaphores[index].signal() == 0 {
400405
_ = try! conn.scalar("SELECT value FROM test")
401-
reads[index] += 1
402406
}
403407
}
404408
}
405-
while !finished {
406-
sleep(1)
407-
finished = reads.reduce(true) { $0 && ($1 > 500) }
408-
}
409+
semaphores.forEach { $0.wait() }
409410
}
410411
}
411412

0 commit comments

Comments
 (0)