11// swift-tools-version: 6.1
22import PackageDescription
3-
4- let deps : [ Package . Dependency ] = [
5- . package ( url: " https://github.com/swiftlang/swift-toolchain-sqlite " , from: " 1.0.7 " ) ,
6- . package ( url: " https://github.com/sqlcipher/SQLCipher.swift.git " , from: " 4.11.0 " )
7- ]
8-
93let applePlatforms : [ PackageDescription . Platform ] = [ . iOS, . macOS, . watchOS, . tvOS, . visionOS]
10- let sqlcipherTraitBuildSettingCondition : BuildSettingCondition ? = . when( platforms: applePlatforms, traits: [ " SQLCipher " ] )
11- let cSettings : [ CSetting ] = [ . define( " SQLITE_HAS_CODEC " , to: nil , sqlcipherTraitBuildSettingCondition) ]
12- let swiftSettings : [ SwiftSetting ] = [ . define( " SQLITE_HAS_CODEC " , sqlcipherTraitBuildSettingCondition) ]
134
14- let targets : [ Target ] = [
15- . target(
16- name: " SQLite " ,
17- dependencies: [
18- . product( name: " SwiftToolchainCSQLite " , package : " swift-toolchain-sqlite " , condition: . when( platforms: [ . linux, . windows, . android] ) ) ,
19- . product( name: " SQLCipher " , package : " SQLCipher.swift " , condition: . when( platforms: applePlatforms, traits: [ " SQLCipher " ] ) )
20- ] ,
21- exclude: [ " Info.plist " ] ,
22- cSettings: cSettings,
23- swiftSettings: swiftSettings
24- )
25- ]
5+ let target : Target = . target(
6+ name: " SQLite " ,
7+ dependencies: [
8+ . product( name: " SwiftToolchainCSQLite " ,
9+ package : " swift-toolchain-sqlite " ,
10+ condition: . when( traits: [ " SwiftToolchainCSQLite " ] ) ) ,
11+ . product( name: " SQLCipher " ,
12+ package : " SQLCipher.swift " ,
13+ condition: . when( platforms: applePlatforms, traits: [ " SQLCipher " ] ) )
14+ ] ,
15+ exclude: [ " Info.plist " ] ,
16+ cSettings: [
17+ . define( " SQLITE_HAS_CODEC " , . when( platforms: applePlatforms, traits: [ " SQLCipher " ] ) )
18+ ]
19+ )
2620
27- let testTargets : [ Target ] = [
28- . testTarget(
29- name: " SQLiteTests " ,
30- dependencies: [ " SQLite " ] ,
31- path: " Tests/SQLiteTests " ,
32- exclude: [ " Info.plist " ] ,
33- resources: [ . copy( " Resources " ) ] ,
34- swiftSettings: swiftSettings
35- )
36- ]
21+ let testTarget : Target = . testTarget(
22+ name: " SQLiteTests " ,
23+ dependencies: [ " SQLite " ] ,
24+ exclude: [ " Info.plist " ] ,
25+ resources: [ . copy( " Resources " ) ]
26+ )
3727
3828let package = Package (
3929 name: " SQLite.swift " ,
@@ -45,20 +35,25 @@ let package = Package(
4535 . visionOS( . v1)
4636 ] ,
4737 products: [
48- . library(
49- name: " SQLite " ,
50- targets: [ " SQLite " ]
51- ) ,
52- . library(
53- name: " SQLite-Dynamic " ,
54- type: . dynamic,
55- targets: [ " SQLite " ]
56- )
38+ . library( name: " SQLite " , targets: [ " SQLite " ] ) ,
39+ . library( name: " SQLite-Dynamic " , type: . dynamic, targets: [ " SQLite " ] )
5740 ] ,
5841 traits: [
59- . trait( name: " SQLCipher " , description: " Enables SQLCipher encryption when a key is supplied to Connection " )
42+ . trait( name: " SystemSQLite " ,
43+ description: " Uses the system-provided SQLite (on Apple platforms) " ) ,
44+ . trait( name: " SwiftToolchainCSQLite " ,
45+ description: " Include SQLite from the Swift toolchain " ) ,
46+ // this will note compile, just included for sake of completeness
47+ . trait( name: " StandaloneSQLite " ,
48+ description: " Assumes SQLite to be already available as 'sqlite3' " ) ,
49+ . trait( name: " SQLCipher " ,
50+ description: " Enables SQLCipher encryption when a key is supplied to Connection " ) ,
51+ . default( enabledTraits: [ " SystemSQLite " ] )
52+ ] ,
53+ dependencies: [
54+ . package ( url: " https://github.com/swiftlang/swift-toolchain-sqlite " , from: " 1.0.7 " ) ,
55+ . package ( url: " https://github.com/sqlcipher/SQLCipher.swift.git " , from: " 4.11.0 " )
6056 ] ,
61- dependencies: deps,
62- targets: targets + testTargets,
57+ targets: [ target, testTarget] ,
6358 swiftLanguageModes: [ . v5] ,
6459)
0 commit comments