Skip to content

Commit 06486f6

Browse files
init csqlite
1 parent 241e322 commit 06486f6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

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

Sources/PowerSyncGRDB/Config/Configuration+PowerSync.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22
import GRDB
33
import PowerSync
44
import SQLite3
5+
import CSQLite
56

67
public extension Configuration {
78
/// Configures GRDB to work with PowerSync by registering required extensions and schema sources.
@@ -23,6 +24,15 @@ public extension Configuration {
2324
mutating func configurePowerSync(
2425
schema: Schema
2526
) {
27+
28+
// This is a bit of a hack. We need to initialize CSQLite before we can use it.
29+
// This needs to happen before the GRDB pool is created.
30+
// Typically the config will be created before the GRDB pool is created, so we need to do this here.
31+
let rc = sqlite3_initialize()
32+
if rc != 0 {
33+
fatalError("Call to sqlite3_initialize() failed with \(rc)")
34+
}
35+
2636
// Register the PowerSync core extension
2737
prepareDatabase { database in
2838
#if os(watchOS)

0 commit comments

Comments
 (0)