Skip to content

Commit b7efc89

Browse files
authored
Merge pull request #1343 from stephencelis/fts5-trait
Adds a new CSQLite dependency with support for FTS5
2 parents 9133ddd + 6c23aa7 commit b7efc89

21 files changed

Lines changed: 94 additions & 39 deletions

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ jobs:
3434
env:
3535
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors --traits SwiftToolchainCSQLite
3636
run: ./run-tests.sh
37+
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test --traits SQLiteSwiftCSQLite)"
38+
env:
39+
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors --traits SQLiteSwiftCSQLite
40+
run: ./run-tests.sh
41+
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test --traits SQLiteSwiftCSQLite,FTS5)"
42+
env:
43+
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors --traits SQLiteSwiftCSQLite,FTS5
44+
run: ./run-tests.sh
3745
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test --traits SQLCipher)"
3846
env:
3947
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors --traits SQLCipher

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ included: # paths to include during linting. `--path` is ignored if present. tak
1212
- Tests
1313
- Package.swift
1414
excluded: # paths to ignore during linting. overridden by `included`.
15+
- .build
1516

1617
identifier_name:
1718
excluded:

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
0.15.5 (tbd), [diff][diff-0.15.5]
22
========================================
3+
* Support more package traits ([#1341][]), including FTS5 ([#1343][])
34
* SQLCipher package manager integration ([#1336][], [#1340][])
5+
* Provide a dynamic library in SPM ([#1342][])
6+
* Added sendability conformance ([#1332][])
47

58
0.15.4 (13-06-2025), [diff][diff-0.15.4]
69
========================================
@@ -15,7 +18,7 @@
1518

1619
0.15.2 (16-04-2024), [diff][diff-0.15.2]
1720
========================================
18-
* fix: visionos to cocoapods ([#1260][])
21+
* fix: visionos to CocoaPods ([#1260][])
1922

2023
0.15.1 (14-04-2024), [diff][diff-0.15.1]
2124
========================================
@@ -276,5 +279,9 @@ For breaking changes, see [Upgrading.md](Documentation/Upgrading.md).
276279
[#1280]: https://github.com/stephencelis/SQLite.swift/pull/1280
277280
[#1315]: https://github.com/stephencelis/SQLite.swift/pull/1315
278281
[#1317]: https://github.com/stephencelis/SQLite.swift/pull/1317
282+
[#1332]: https://github.com/stephencelis/SQLite.swift/pull/1332
279283
[#1336]: https://github.com/stephencelis/SQLite.swift/pull/1336
280284
[#1340]: https://github.com/stephencelis/SQLite.swift/pull/1340
285+
[#1341]: https://github.com/stephencelis/SQLite.swift/pull/1341
286+
[#1342]: https://github.com/stephencelis/SQLite.swift/pull/1342
287+
[#1343]: https://github.com/stephencelis/SQLite.swift/pull/1343

Documentation/Index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ SQLite.swift for different use cases.
132132
]
133133
```
134134

135-
| Trait | Description |
136-
|--------------------------|---------------------------------------------------|
137-
| `SystemSQLite` (default) | Uses the system SQLite (provided by Apple) |
138-
| `SwiftToolchainCSQLite` | Embeds the SQLite provided by [swift-toolchain][] |
139-
| `StandaloneSQLite` | Only used by CocoaPods |
140-
| `SQLCipher` | Embeds [SQLCipher][] (see below) |
135+
| Trait | Description |
136+
|--------------------------|-----------------------------------------------------|
137+
| `SystemSQLite` (default) | Uses the system SQLite (provided by Apple) |
138+
| `SwiftToolchainCSQLite` | Embeds the SQLite provided by [swift-toolchain][] |
139+
| `SQLiteSwiftCSQLite` | Embeds a [custom SQLite][] based on swift-toolchain |
140+
| `StandaloneSQLite` | Only used by CocoaPods |
141+
| `SQLCipher` | Embeds [SQLCipher][] (see below) |
142+
| `FTS5` | Enables FTS5, only works with `SQLiteSwiftCSQLite` |
141143

142144
[traits]: https://docs.swift.org/swiftpm/documentation/packagemanagerdocs/packagetraits/
145+
[custom SQLite]: https://github.com/stephencelis/CSQLite/tree/SQLite.swift
143146
[swift-toolchain]: https://github.com/swiftlang/swift-toolchain-sqlite
144147

145148
#### Using SQLite.swift with SQLCipher

Package.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ let target: Target = .target(
88
.product(name: "SwiftToolchainCSQLite",
99
package: "swift-toolchain-sqlite",
1010
condition: .when(traits: ["SwiftToolchainCSQLite"])),
11+
.product(name: "SQLiteSwiftCSQLite",
12+
package: "CSQLite",
13+
condition: .when(traits: ["SQLiteSwiftCSQLite"])),
1114
.product(name: "SQLCipher",
1215
package: "SQLCipher.swift",
1316
condition: .when(platforms: applePlatforms, traits: ["SQLCipher"]))
@@ -43,16 +46,23 @@ let package = Package(
4346
description: "Uses the system-provided SQLite (on Apple platforms)"),
4447
.trait(name: "SwiftToolchainCSQLite",
4548
description: "Include SQLite from the Swift toolchain"),
49+
.trait(name: "SQLiteSwiftCSQLite",
50+
description: "Include SQLite from SQLite.swift, based on the toolchain version"),
4651
// this will note compile, just included for sake of completeness
4752
.trait(name: "StandaloneSQLite",
4853
description: "Assumes SQLite to be already available as 'sqlite3'"),
4954
.trait(name: "SQLCipher",
5055
description: "Enables SQLCipher encryption when a key is supplied to Connection"),
56+
.trait(name: "FTS5",
57+
description: "Enables FTS5 in the embedded SQLite (only supported by SQLiteSwiftCSQLite)"),
5158
.default(enabledTraits: ["SystemSQLite"])
5259
],
5360
dependencies: [
5461
.package(url: "https://github.com/swiftlang/swift-toolchain-sqlite", from: "1.0.7"),
55-
.package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.11.0")
62+
.package(url: "https://github.com/stephencelis/CSQLite",
63+
branch: "SQLite.swift",
64+
traits: [.trait(name: "FTS5", condition: .when(traits: ["FTS5"]))]),
65+
.package(url: "https://github.com/sqlcipher/SQLCipher.swift", from: "4.11.0")
5666
],
5767
targets: [target, testTarget],
5868
swiftLanguageModes: [.v5],

SQLite.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
19A1725658E480B9B378F28B /* Connection+SchemaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17CA1DF7D0F7C9A94C51C /* Connection+SchemaTests.swift */; };
5353
19A1726002D24C14F876C8FE /* ValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17AE284BB1DF31D1B753E /* ValueTests.swift */; };
5454
19A172F71EFD65342072D8D2 /* SchemaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A171A7714C6524093255C5 /* SchemaTests.swift */; };
55-
19A173088B85A7E18E8582A7 /* FTSIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */; };
55+
19A173088B85A7E18E8582A7 /* FTS5IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */; };
5656
19A173389E53CB24DFA8CEDD /* QueryIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17CAE60446607E99C22A6 /* QueryIntegrationTests.swift */; };
5757
19A173465F23C64DF3DF469B /* ConnectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17855BD524FF888265B3C /* ConnectionTests.swift */; };
5858
19A173668D948AD4DF1F5352 /* DateAndTimeFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BA55DABB480F9020C8A /* DateAndTimeFunctions.swift */; };
@@ -72,7 +72,7 @@
7272
19A17490543609FCED53CACC /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1710E73A46D5AC721CDA9 /* Errors.swift */; };
7373
19A1750CEE9B05267995CF3D /* FTS5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1730E4390C775C25677D1 /* FTS5.swift */; };
7474
19A1750EF4A5F92954A451FF /* Connection+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A170A97B51DC5EE365F3C5 /* Connection+Schema.swift */; };
75-
19A1755C49154C87304C9146 /* FTSIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */; };
75+
19A1755C49154C87304C9146 /* FTS5IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */; };
7676
19A1760CE25615CA015E2E5F /* Connection+Pragmas.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17F285B767BFACD96714B /* Connection+Pragmas.swift */; };
7777
19A176376CB6A94759F7980A /* Connection+Aggregation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A175A9CB446640AE6F2200 /* Connection+Aggregation.swift */; };
7878
19A1766135CE9786B1878603 /* ValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17AE284BB1DF31D1B753E /* ValueTests.swift */; };
@@ -84,7 +84,7 @@
8484
19A1773A335CAB9D0AE14E8E /* SchemaChanger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A171B262DDE8718513CFDA /* SchemaChanger.swift */; };
8585
19A17746150A815944A6820B /* SelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17EC0C43015063945D32E /* SelectTests.swift */; };
8686
19A1776BD5127DFDF847FF1F /* FTS5Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17B96EBD42C878E609CDC /* FTS5Tests.swift */; };
87-
19A177909023B7B940C5805E /* FTSIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */; };
87+
19A177909023B7B940C5805E /* FTS5IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */; };
8888
19A177AA5922527BBDC77CF9 /* QueryIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17CAE60446607E99C22A6 /* QueryIntegrationTests.swift */; };
8989
19A177C25834473FAB32CF3B /* SchemaChangerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17FDB0B0CFB8987906FD0 /* SchemaChangerTests.swift */; };
9090
19A177D5C6542E2D572162E5 /* QueryIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17CAE60446607E99C22A6 /* QueryIntegrationTests.swift */; };
@@ -265,7 +265,7 @@
265265
DEB306EF2B61CF9500F9D46B /* SchemaChangerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17FDB0B0CFB8987906FD0 /* SchemaChangerTests.swift */; };
266266
DEB306F02B61CF9500F9D46B /* Connection+SchemaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17CA1DF7D0F7C9A94C51C /* Connection+SchemaTests.swift */; };
267267
DEB306F12B61CF9500F9D46B /* FTS5Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17B96EBD42C878E609CDC /* FTS5Tests.swift */; };
268-
DEB306F22B61CF9500F9D46B /* FTSIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */; };
268+
DEB306F22B61CF9500F9D46B /* FTS5IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */; };
269269
DEB306F32B61CF9500F9D46B /* FTS4Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1715904F7B6851FCB5EF6 /* FTS4Tests.swift */; };
270270
DEB306F42B61CF9500F9D46B /* ExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A170F141BF21946D159083 /* ExpressionTests.swift */; };
271271
DEB306F52B61CF9500F9D46B /* StatementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A1756EB81E9F7F45B12A78 /* StatementTests.swift */; };
@@ -407,7 +407,7 @@
407407
19A17B93B48B5560E6E51791 /* Fixtures.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Fixtures.swift; sourceTree = "<group>"; };
408408
19A17B96EBD42C878E609CDC /* FTS5Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5Tests.swift; sourceTree = "<group>"; };
409409
19A17BA55DABB480F9020C8A /* DateAndTimeFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateAndTimeFunctions.swift; sourceTree = "<group>"; };
410-
19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTSIntegrationTests.swift; sourceTree = "<group>"; };
410+
19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5IntegrationTests.swift; sourceTree = "<group>"; };
411411
19A17C60D3464461057E4D63 /* Connection+PragmaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Connection+PragmaTests.swift"; sourceTree = "<group>"; };
412412
19A17CA1DF7D0F7C9A94C51C /* Connection+SchemaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Connection+SchemaTests.swift"; sourceTree = "<group>"; };
413413
19A17CAE60446607E99C22A6 /* QueryIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryIntegrationTests.swift; sourceTree = "<group>"; };
@@ -611,7 +611,7 @@
611611
isa = PBXGroup;
612612
children = (
613613
19A17B96EBD42C878E609CDC /* FTS5Tests.swift */,
614-
19A17BE1CC4AD4036BAB8EE0 /* FTSIntegrationTests.swift */,
614+
19A17BE1CC4AD4036BAB8EE0 /* FTS5IntegrationTests.swift */,
615615
19A1715904F7B6851FCB5EF6 /* FTS4Tests.swift */,
616616
19A1787E16C8562C09C076F5 /* CipherTests.swift */,
617617
19A17162C9861E5C4900455D /* RTreeTests.swift */,
@@ -1183,7 +1183,7 @@
11831183
19A17FC04708C6ED637DDFD4 /* SchemaChangerTests.swift in Sources */,
11841184
19A17188B4D96636F9C0C209 /* Connection+SchemaTests.swift in Sources */,
11851185
19A17FACE8E4D54A50BA934E /* FTS5Tests.swift in Sources */,
1186-
19A177909023B7B940C5805E /* FTSIntegrationTests.swift in Sources */,
1186+
19A177909023B7B940C5805E /* FTS5IntegrationTests.swift in Sources */,
11871187
19A17E1DD976D5CE80018749 /* FTS4Tests.swift in Sources */,
11881188
DBB93D5C2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
11891189
19A17411403D60640467209E /* ExpressionTests.swift in Sources */,
@@ -1307,7 +1307,7 @@
13071307
DEB306EF2B61CF9500F9D46B /* SchemaChangerTests.swift in Sources */,
13081308
DEB306F02B61CF9500F9D46B /* Connection+SchemaTests.swift in Sources */,
13091309
DEB306F12B61CF9500F9D46B /* FTS5Tests.swift in Sources */,
1310-
DEB306F22B61CF9500F9D46B /* FTSIntegrationTests.swift in Sources */,
1310+
DEB306F22B61CF9500F9D46B /* FTS5IntegrationTests.swift in Sources */,
13111311
DEB306F32B61CF9500F9D46B /* FTS4Tests.swift in Sources */,
13121312
DEB306F42B61CF9500F9D46B /* ExpressionTests.swift in Sources */,
13131313
DEB306F52B61CF9500F9D46B /* StatementTests.swift in Sources */,
@@ -1388,7 +1388,7 @@
13881388
19A177C25834473FAB32CF3B /* SchemaChangerTests.swift in Sources */,
13891389
19A1725658E480B9B378F28B /* Connection+SchemaTests.swift in Sources */,
13901390
19A178DA2BB5970778CCAF13 /* FTS5Tests.swift in Sources */,
1391-
19A1755C49154C87304C9146 /* FTSIntegrationTests.swift in Sources */,
1391+
19A1755C49154C87304C9146 /* FTS5IntegrationTests.swift in Sources */,
13921392
19A17444861E1443143DEB44 /* FTS4Tests.swift in Sources */,
13931393
DBB93D5A2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
13941394
19A17DD33C2E43DD6EE05A60 /* ExpressionTests.swift in Sources */,
@@ -1471,7 +1471,7 @@
14711471
19A1766AC10D13C4EFF349AD /* SchemaChangerTests.swift in Sources */,
14721472
19A17B36ABC6006AB80F693C /* Connection+SchemaTests.swift in Sources */,
14731473
19A1776BD5127DFDF847FF1F /* FTS5Tests.swift in Sources */,
1474-
19A173088B85A7E18E8582A7 /* FTSIntegrationTests.swift in Sources */,
1474+
19A173088B85A7E18E8582A7 /* FTS5IntegrationTests.swift in Sources */,
14751475
19A178767223229E61C5066F /* FTS4Tests.swift in Sources */,
14761476
DBB93D5B2A22A373009BB96E /* SchemaReaderTests.swift in Sources */,
14771477
19A1781CBA8968ABD3E00877 /* ExpressionTests.swift in Sources */,

Sources/SQLite/Core/Backup.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import sqlite3
3030
import SQLCipher
3131
#elseif SwiftToolchainCSQLite
3232
import SwiftToolchainCSQLite
33+
#elseif SQLiteSwiftCSQLite
34+
import SQLiteSwiftCSQLite
3335
#else
3436
import SQLite3 // SystemSQLite
3537
#endif

Sources/SQLite/Core/Connection+Aggregation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import sqlite3
55
import SQLCipher
66
#elseif SwiftToolchainCSQLite
77
import SwiftToolchainCSQLite
8+
#elseif SQLiteSwiftCSQLite
9+
import SQLiteSwiftCSQLite
810
#else
911
import SQLite3 // SystemSQLite
1012
#endif

Sources/SQLite/Core/Connection.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import sqlite3
3030
import SQLCipher
3131
#elseif SwiftToolchainCSQLite
3232
import SwiftToolchainCSQLite
33+
#elseif SQLiteSwiftCSQLite
34+
import SQLiteSwiftCSQLite
3335
#else
3436
import SQLite3 // SystemSQLite
3537
#endif

Sources/SQLite/Core/Result.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import sqlite3
44
import SQLCipher
55
#elseif SwiftToolchainCSQLite
66
import SwiftToolchainCSQLite
7+
#elseif SQLiteSwiftCSQLite
8+
import SQLiteSwiftCSQLite
79
#else
810
import SQLite3 // SystemSQLite
911
#endif

0 commit comments

Comments
 (0)