Skip to content
7 changes: 2 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ let deps: [Package.Dependency] = [
let applePlatforms: [PackageDescription.Platform] = [.iOS, .macOS, .watchOS, .tvOS, .visionOS]
let sqlcipherTraitBuildSettingCondition: BuildSettingCondition? = .when(platforms: applePlatforms, traits: ["SQLCipher"])
let cSettings: [CSetting] = [.define("SQLITE_HAS_CODEC", to: nil, sqlcipherTraitBuildSettingCondition)]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@R4N does this define actually need to be set? There are no C files to be compiled in this project.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the sqlite3.h header that SQLCipher exposes, we'll need that other c flag to enable sqlite3_key* and sqlite3_rekey*. If you remove it, you should see errors along the lines of:

Cannot find 'sqlite3_key_v2' in scope
Cannot find 'sqlite3_rekey_v2' in scope

let swiftSettings: [SwiftSetting] = [.define("SQLITE_HAS_CODEC", sqlcipherTraitBuildSettingCondition)]

let targets: [Target] = [
.target(
Expand All @@ -19,8 +18,7 @@ let targets: [Target] = [
.product(name: "SQLCipher", package: "SQLCipher.swift", condition: .when(platforms: applePlatforms, traits: ["SQLCipher"]))
],
exclude: ["Info.plist"],
cSettings: cSettings,
swiftSettings: swiftSettings
cSettings: cSettings
)
]

Expand All @@ -30,8 +28,7 @@ let testTargets: [Target] = [
dependencies: ["SQLite"],
path: "Tests/SQLiteTests",
exclude: ["Info.plist"],
resources: [.copy("Resources")],
swiftSettings: swiftSettings
resources: [.copy("Resources")]
)
]

Expand Down
2 changes: 1 addition & 1 deletion SQLite.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Pod::Spec.new do |s|
ss.resource_bundle = { 'SQLite.swift' => 'Sources/SQLite/PrivacyInfo.xcprivacy' }

ss.xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC',
'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLCipher',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1'
}
ss.dependency 'SQLCipher', '>= 4.0.0'
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLite/Core/Connection+Attach.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

extension Connection {
#if SQLITE_HAS_CODEC
#if SQLCipher
/// See https://www.zetetic.net/sqlcipher/sqlcipher-api/#attach
public func attach(_ location: Location, as schemaName: String, key: String? = nil) throws {
if let key {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLite/Extensions/Cipher.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if SQLITE_HAS_CODEC
#if SQLCipher
import SQLCipher

/// Extension methods for [SQLCipher](https://www.zetetic.net/sqlcipher/).
Expand Down
2 changes: 1 addition & 1 deletion Tests/SQLiteTests/Extensions/CipherTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if SQLITE_HAS_CODEC
#if SQLCipher
import XCTest
import SQLite
import SQLCipher
Expand Down