1- // swift-tools-version:6.0
1+ // swift-tools-version:6.1
22// The swift-tools-version declares the minimum version of Swift required to build this package.
33
44import Foundation
@@ -27,23 +27,11 @@ if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
2727 dependencies. append ( . package ( url: " https://github.com/apple/swift-docc-plugin " , from: " 1.0.0 " ) )
2828}
2929
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 " ) )
4735
4836let package = Package (
4937 name: " GRDB " ,
@@ -59,14 +47,18 @@ let package = Package(
5947 . library( name: " GRDB " , targets: [ " GRDB " ] ) ,
6048 . library( name: " GRDB-dynamic " , type: . dynamic, targets: [ " GRDB " ] ) ,
6149 ] ,
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+ ] ,
6254 dependencies: dependencies,
6355 targets: [
6456 . systemLibrary(
6557 name: " GRDBSQLite " ,
6658 providers: [ . apt( [ " libsqlite3-dev " ] ) ] ) ,
6759 . target(
6860 name: " GRDB " ,
69- dependencies: targetDependencies ,
61+ dependencies: GRDBDependencies ,
7062 path: " GRDB " ,
7163 resources: [ . copy( " PrivacyInfo.xcprivacy " ) ] ,
7264 cSettings: cSettings,
0 commit comments