Skip to content

Commit e1aca1a

Browse files
committed
Explicitly pass threadsafe 2
1 parent 3a4fb66 commit e1aca1a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Package.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@ var conditionalDependencies: [Package.Dependency] = [
2222
.package(
2323
url: "https://github.com/sbooth/CSQLite.git",
2424
from: "3.50.4",
25-
traits: ["ENABLE_SESSION"]
25+
traits: [
26+
.defaults,
27+
// CSQLite uses THREADSAFE=0 by default, which breaks PowerSync because we're using SQLite on
28+
// multiple threads (it can lead to race conditions when closing connecting sharing resources
29+
// like shared memory, causing crashes).
30+
// THREADSAFE=2 overrides the default, and is safe to use as long as a single SQLite connection
31+
// is not shared between threads.
32+
// TODO: Technically, we should not use .defaults because there's a logical conflict between
33+
// the threadsafe options. Instead, we should spell out all defaults again and remove that
34+
// thread-safety option.
35+
// However, despite the docs explicitly saying something else, it looks like there's no way to
36+
// disable default traits anyway (XCode compiles sqlite3.c with the default option even without
37+
// .defaults being included here).
38+
"THREADSAFE_2",
39+
"ENABLE_SESSION"
40+
]
2641
)
2742
]
2843
var conditionalTargets: [Target] = []

0 commit comments

Comments
 (0)