@@ -12,42 +12,26 @@ let localKotlinSdkOverride: String? = nil
1212// local build of the core extension.
1313let localCoreExtension : String ? = nil
1414
15+ // Currently encryption is required for GRDB integration
16+ let encryption = true
17+
1518// Our target and dependency setup is different when a local Kotlin SDK is used. Without the local
1619// SDK, we have no package dependency on Kotlin and download the XCFramework from Kotlin releases as
1720// a binary target.
1821// With a local SDK, we point to a `Package.swift` within the Kotlin SDK containing a target pointing
1922// towards a local framework build
2023var conditionalDependencies : [ Package . Dependency ] = [
21- // We can't currently build with GRDB using this package
22- // We could use traits for this
23-
24- // .package(
25- // url: "https://github.com/sbooth/CSQLite.git",
26- // from: "3.50.4",
27- // traits: [
28- // .defaults,
29- // // CSQLite uses THREADSAFE=0 by default, which breaks PowerSync because we're using SQLite on
30- // // multiple threads (it can lead to race conditions when closing connections sharing resources
31- // // like shared memory, causing crashes).
32- // // THREADSAFE=2 overrides the default, and is safe to use as long as a single SQLite connection
33- // // is not shared between threads.
34- // // TODO: Technically, we should not use .defaults because there's a logical conflict between
35- // // the threadsafe options. Instead, we should spell out all defaults again and remove that
36- // // thread-safety option.
37- // // However, despite the docs explicitly saying something else, it looks like there's no way to
38- // // disable default traits anyway (XCode compiles sqlite3.c with the default option even without
39- // // .defaults being included here).
40- // "THREADSAFE_2",
41- // "ENABLE_SESSION"
42- // ]
43- // )
44-
45- // Using SQLCipher here since GRDB doesn't compile with CSQLite
46- . package ( url: " https://github.com/sqlcipher/SQLCipher.swift.git " , from: " 4.10.0 " )
4724]
25+
4826var conditionalTargets : [ Target ] = [ ]
4927var kotlinTargetDependency = Target . Dependency. target ( name: " PowerSyncKotlin " )
5028
29+ if encryption {
30+ conditionalDependencies. append ( . package ( url: " https://github.com/sqlcipher/SQLCipher.swift.git " , from: " 4.10.0 " ) )
31+ } else {
32+ conditionalDependencies. append ( . package ( url: " https://github.com/sbooth/CSQLite.git " , from: " 3.50.4 " ) )
33+ }
34+
5135if let kotlinSdkPath = localKotlinSdkOverride {
5236 // We can't depend on local XCFrameworks outside of this project's root, so there's a Package.swift
5337 // in the PowerSyncKotlin project pointing towards a local build.
@@ -114,15 +98,17 @@ let package = Package(
11498 dependencies: [
11599 kotlinTargetDependency,
116100 . product( name: " PowerSyncSQLiteCore " , package : corePackageName) ,
117- // .product(name: "CSQLite", package: "CSQLite")
118- . product( name: " SQLCipher " , package : " SQLCipher.swift " )
101+ encryption ?
102+ . product( name: " SQLCipher " , package : " SQLCipher.swift " ) :
103+ . product( name: " CSQLite " , package : " CSQLite " )
119104 ]
120105 ) ,
121106 . target(
122107 name: " PowerSyncGRDB " ,
123108 dependencies: [
124109 . target( name: " PowerSync " ) ,
125110 . product( name: " GRDB " , package : " GRDB.swift " )
111+
126112 ]
127113 ) ,
128114 . testTarget(
0 commit comments