Skip to content

Commit 91092ba

Browse files
committed
Update to use package traits to control whether SQLCipher is used
1 parent c49ed6d commit 91092ba

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ jobs:
8383
fail-fast: false
8484
matrix:
8585
include:
86-
- xcode: "Xcode_16.1.app"
87-
runsOn: macOS-14
88-
name: "Xcode 16.1"
86+
- xcode: "Xcode_16.3.app"
87+
runsOn: macOS-15
88+
name: "Xcode 16.3"
8989
steps:
9090
- uses: actions/checkout@v4
9191
- name: ${{ matrix.name }}
92-
run: GRDBCIPHER="https://github.com/skiptools/swift-sqlcipher.git#1.2.1" swift test
92+
run: GRDBCIPHER=1 swift test
9393
SQLCipher3:
9494
name: SQLCipher3
9595
runs-on: ${{ matrix.runsOn }}

Package.swift

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
import 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

4836
let 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

Comments
 (0)