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,15 +35,24 @@ let package = Package(
4535 . visionOS( . v1)
4636 ] ,
4737 products: [
48- . library(
49- name: " SQLite " ,
50- targets: [ " SQLite " ]
51- )
38+ . library( name: " SQLite " , targets: [ " SQLite " ] )
5239 ] ,
5340 traits: [
54- . trait( name: " SQLCipher " , description: " Enables SQLCipher encryption when a key is supplied to Connection " )
41+ . trait( name: " SystemSQLite " ,
42+ description: " Uses the system-provided SQLite (on Apple platforms) " ) ,
43+ . trait( name: " SwiftToolchainCSQLite " ,
44+ description: " Include SQLite from the Swift toolchain " ) ,
45+ // this will note compile, just included for sake of completeness
46+ . trait( name: " StandaloneSQLite " ,
47+ description: " Assumes SQLite to be already available as 'sqlite3' " ) ,
48+ . trait( name: " SQLCipher " ,
49+ description: " Enables SQLCipher encryption when a key is supplied to Connection " ) ,
50+ . default( enabledTraits: [ " SystemSQLite " ] )
51+ ] ,
52+ dependencies: [
53+ . package ( url: " https://github.com/swiftlang/swift-toolchain-sqlite " , from: " 1.0.7 " ) ,
54+ . package ( url: " https://github.com/sqlcipher/SQLCipher.swift.git " , from: " 4.11.0 " )
5555 ] ,
56- dependencies: deps,
57- targets: targets + testTargets,
56+ targets: [ target, testTarget] ,
5857 swiftLanguageModes: [ . v5] ,
5958)
0 commit comments