1
- // swift-tools-version:6.0
1
+ // swift-tools-version:6.1
2
2
// The swift-tools-version declares the minimum version of Swift required to build this package.
3
3
4
4
import Foundation
@@ -27,23 +27,11 @@ if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
27
27
dependencies. append ( . package ( url: " https://github.com/apple/swift-docc-plugin " , from: " 1.0.0 " ) )
28
28
}
29
29
30
- var targetDependencies : [ Target . Dependency ] = [ " GRDBSQLite " ]
31
-
32
-
33
- var GRDBCIPHER = ProcessInfo . processInfo. environment [ " GRDBCIPHER " ]
34
- // e.g.:
35
- //GRDBCIPHER="https://github.com/skiptools/swift-sqlcipher.git#1.2.1"
36
- if let SQLCipherRepo = GRDBCIPHER ? . split ( separator: " # " ) . first,
37
- let SQLCipherVersion = GRDBCIPHER ? . split ( separator: " # " ) . last,
38
- let SQLCipherRepoURL = URL ( string: SQLCipherRepo . description) {
39
- swiftSettings. append ( . define( " GRDBCIPHER " ) )
40
- targetDependencies = [ . product( name: " SQLCipher " , package : SQLCipherRepoURL . deletingPathExtension ( ) . lastPathComponent) ]
41
- if let version = Version ( SQLCipherVersion . description) { // numeric version
42
- dependencies. append ( . package ( url: SQLCipherRepoURL . absoluteString, from: version) )
43
- } else { // branch
44
- dependencies. append ( . package ( url: SQLCipherRepoURL . absoluteString, branch: SQLCipherVersion . description) )
45
- }
46
- }
30
+ // whether the "GRDBCIPHER" should be enabled by default; used for testing
31
+ var GRDBCIPHERENV = ( ProcessInfo . processInfo. environment [ " GRDBCIPHER " ] ?? " 0 " ) != " 0 "
32
+ var GRDBDependencies : [ Target . Dependency ] = [ " GRDBSQLite " ]
33
+ GRDBDependencies += [ . product( name: " SQLCipher " , package : " swift-sqlcipher " , condition: . when( traits: [ " GRDBCIPHER " ] ) ) ]
34
+ dependencies. append ( . package ( url: " https://github.com/skiptools/swift-sqlcipher.git " , from: " 1.3.0 " ) )
47
35
48
36
let package = Package (
49
37
name: " GRDB " ,
@@ -59,14 +47,18 @@ let package = Package(
59
47
. library( name: " GRDB " , targets: [ " GRDB " ] ) ,
60
48
. library( name: " GRDB-dynamic " , type: . dynamic, targets: [ " GRDB " ] ) ,
61
49
] ,
50
+ traits: [
51
+ . trait( name: " GRDBCIPHER " , description: " Use the SQLCipher library rather than the vendored SQLite " ) ,
52
+ . default( enabledTraits: GRDBCIPHERENV ? [ " GRDBCIPHER " ] : [ ] ) // GRDBCIPHER is not enabled by default
53
+ ] ,
62
54
dependencies: dependencies,
63
55
targets: [
64
56
. systemLibrary(
65
57
name: " GRDBSQLite " ,
66
58
providers: [ . apt( [ " libsqlite3-dev " ] ) ] ) ,
67
59
. target(
68
60
name: " GRDB " ,
69
- dependencies: targetDependencies ,
61
+ dependencies: GRDBDependencies ,
70
62
path: " GRDB " ,
71
63
resources: [ . copy( " PrivacyInfo.xcprivacy " ) ] ,
72
64
cSettings: cSettings,
0 commit comments