Skip to content

Commit 0064457

Browse files
committed
Only force embedded SQLite for Android
macOS and Linux keep SQLite.swift's own default trait for the platform (system SQLite on Apple, embedded on Linux); Android is the only target that needs the embedded copy forced, detected via the TARGET_OS_ANDROID env var set when cross-compiling.
1 parent 414ad09 commit 0064457

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎Package.swift‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// swift-tools-version: 6.1
22
import PackageDescription
3+
import Foundation
4+
5+
// Android has no system libsqlite3, so it needs SQLite.swift's embedded
6+
// copy. macOS and Linux keep SQLite.swift's own default for the platform.
7+
let isAndroid = ProcessInfo.processInfo.environment["TARGET_OS_ANDROID"] == "1"
8+
9+
let sqliteDependency: Package.Dependency = isAndroid
10+
? .package(
11+
url: "https://github.com/stephencelis/SQLite.swift.git",
12+
from: "0.16.0",
13+
traits: ["SQLiteSwiftCSQLite"]
14+
)
15+
: .package(
16+
url: "https://github.com/stephencelis/SQLite.swift.git",
17+
from: "0.16.0"
18+
)
319

420
let package = Package(
521
name: "CoreModel-SQLite",
@@ -20,11 +36,7 @@ let package = Package(
2036
url: "https://github.com/PureSwift/CoreModel",
2137
from: "2.6.3"
2238
),
23-
.package(
24-
url: "https://github.com/stephencelis/SQLite.swift.git",
25-
from: "0.16.0",
26-
traits: ["SQLiteSwiftCSQLite"]
27-
)
39+
sqliteDependency
2840
],
2941
targets: [
3042
.target(

0 commit comments

Comments
 (0)