Skip to content

Commit 36a3b76

Browse files
Test: use SQLCipher
1 parent 06486f6 commit 36a3b76

File tree

6 files changed

+48
-42
lines changed

6 files changed

+48
-42
lines changed

Demo/GRDB Demo/GRDB Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.resolved

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ let localCoreExtension: String? = nil
1818
// With a local SDK, we point to a `Package.swift` within the Kotlin SDK containing a target pointing
1919
// towards a local framework build
2020
var conditionalDependencies: [Package.Dependency] = [
21-
.package(
22-
url: "https://github.com/sbooth/CSQLite.git",
23-
from: "3.50.4",
24-
traits: [
25-
.defaults,
26-
// CSQLite uses THREADSAFE=0 by default, which breaks PowerSync because we're using SQLite on
27-
// multiple threads (it can lead to race conditions when closing connections sharing resources
28-
// like shared memory, causing crashes).
29-
// THREADSAFE=2 overrides the default, and is safe to use as long as a single SQLite connection
30-
// is not shared between threads.
31-
// TODO: Technically, we should not use .defaults because there's a logical conflict between
32-
// the threadsafe options. Instead, we should spell out all defaults again and remove that
33-
// thread-safety option.
34-
// However, despite the docs explicitly saying something else, it looks like there's no way to
35-
// disable default traits anyway (XCode compiles sqlite3.c with the default option even without
36-
// .defaults being included here).
37-
"THREADSAFE_2",
38-
"ENABLE_SESSION"
39-
]
40-
)
21+
// .package(
22+
// url: "https://github.com/sbooth/CSQLite.git",
23+
// from: "3.50.4",
24+
// traits: [
25+
// .defaults,
26+
// // CSQLite uses THREADSAFE=0 by default, which breaks PowerSync because we're using SQLite on
27+
// // multiple threads (it can lead to race conditions when closing connections sharing resources
28+
// // like shared memory, causing crashes).
29+
// // THREADSAFE=2 overrides the default, and is safe to use as long as a single SQLite connection
30+
// // is not shared between threads.
31+
// // TODO: Technically, we should not use .defaults because there's a logical conflict between
32+
// // the threadsafe options. Instead, we should spell out all defaults again and remove that
33+
// // thread-safety option.
34+
// // However, despite the docs explicitly saying something else, it looks like there's no way to
35+
// // disable default traits anyway (XCode compiles sqlite3.c with the default option even without
36+
// // .defaults being included here).
37+
// "THREADSAFE_2",
38+
// "ENABLE_SESSION"
39+
// ]
40+
// )
41+
.package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.10.0")
4142
]
4243
var conditionalTargets: [Target] = []
4344
var kotlinTargetDependency = Target.Dependency.target(name: "PowerSyncKotlin")
@@ -108,7 +109,8 @@ let package = Package(
108109
dependencies: [
109110
kotlinTargetDependency,
110111
.product(name: "PowerSyncSQLiteCore", package: corePackageName),
111-
.product(name: "CSQLite", package: "CSQLite")
112+
// .product(name: "CSQLite", package: "CSQLite")
113+
.product(name: "SQLCipher", package: "SQLCipher.swift")
112114
]
113115
),
114116
.target(

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import CSQLite
1+
import SQLCipher
22
import Foundation
33
import PowerSyncKotlin
44

Sources/PowerSyncGRDB/Config/Configuration+PowerSync.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import GRDB
33
import PowerSync
44
import SQLite3
5-
import CSQLite
5+
import SQLCipher
66

77
public extension Configuration {
88
/// Configures GRDB to work with PowerSync by registering required extensions and schema sources.

Sources/PowerSyncGRDB/Connections/GRDBConnectionPool.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ actor GRDBConnectionPool: SQLiteConnectionPoolProtocol {
7575
try database.notifyChanges(in: Table(table))
7676
}
7777
}
78+
79+
if case .failure(let error) = result.blockResult {
80+
throw error
81+
}
7882
}
7983

8084
func withAllConnections(

0 commit comments

Comments
 (0)