mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-22 04:00:39 +00:00
Prepare support for SPM+SQLCipher
This commit is contained in:
1 parent
14fdba1ef3
commit
79276d7f68
5 files changed
+56
No files matched your search
@@ -6,6 +6,7 @@ import SQLite3
|
||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||
#elseif SQLCipher
|
||||
import SQLCipher
|
||||
import GRDBSQLCipher
|
||||
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||
import GRDBSQLite
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,12 @@ if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
|
||||
dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"))
|
||||
}
|
||||
|
||||
// GRDB+SQLCipher: Uncomment those lines
|
||||
//dependencies.append(.package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.11.0"))
|
||||
//cSettings.append(.define("SQLITE_HAS_CODEC"))
|
||||
//swiftSettings.append(.define("SQLITE_HAS_CODEC"))
|
||||
//swiftSettings.append(.define("SQLCipher"))
|
||||
|
||||
let package = Package(
|
||||
name: "GRDB",
|
||||
defaultLocalization: "en", // for tests
|
||||
@@ -46,19 +52,30 @@ let package = Package(
|
||||
.watchOS(.v7),
|
||||
],
|
||||
products: [
|
||||
// GRDB+SQLCipher: Delete the GRDBSQLite library
|
||||
.library(name: "GRDBSQLite", targets: ["GRDBSQLite"]),
|
||||
.library(name: "GRDB", targets: ["GRDB"]),
|
||||
.library(name: "GRDB-dynamic", type: .dynamic, targets: ["GRDB"]),
|
||||
],
|
||||
dependencies: dependencies,
|
||||
targets: [
|
||||
// GRDB+SQLCipher: Delete the GRDBSQLite target
|
||||
.systemLibrary(
|
||||
name: "GRDBSQLite",
|
||||
providers: [.apt(["libsqlite3-dev"])]),
|
||||
// GRDB+SQLCipher: Uncomment the GRDBSQLCipher target
|
||||
//.target(
|
||||
// name: "GRDBSQLCipher",
|
||||
// dependencies: [.product(name: "SQLCipher", package: "SQLCipher.swift")]
|
||||
//),
|
||||
.target(
|
||||
name: "GRDB",
|
||||
dependencies: [
|
||||
// GRDB+SQLCipher: Delete the GRDBSQLite dependency
|
||||
.target(name: "GRDBSQLite"),
|
||||
// GRDB+SQLCipher: Uncomment the SQLCipher and GRDBSQLCipher dependencies
|
||||
//.product(name: "SQLCipher", package: "SQLCipher.swift"),
|
||||
//.target(name: "GRDBSQLCipher"),
|
||||
],
|
||||
path: "GRDB",
|
||||
resources: [.copy("PrivacyInfo.xcprivacy")],
|
||||
@@ -85,6 +102,7 @@ let package = Package(
|
||||
.copy("GRDBTests/Betty.jpeg"),
|
||||
.copy("GRDBTests/InflectionsTests.json"),
|
||||
.copy("GRDBTests/Issue1383.sqlite"),
|
||||
.copy("GRDBTests/db.SQLCipher3"),
|
||||
],
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings + [
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// empty c-file
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef grdb_config_h
|
||||
#define grdb_config_h
|
||||
|
||||
#include <SQLCipher/sqlite3.h>
|
||||
|
||||
typedef void(*_errorLogCallback)(void *pArg, int iErrCode, const char *zMsg);
|
||||
|
||||
/// Wrapper around sqlite3_config(SQLITE_CONFIG_LOG, ...) which is a variadic
|
||||
/// function that can't be used from Swift.
|
||||
static inline void _registerErrorLogCallback(_errorLogCallback callback) {
|
||||
sqlite3_config(SQLITE_CONFIG_LOG, callback, 0);
|
||||
}
|
||||
|
||||
#if SQLITE_VERSION_NUMBER >= 3029000
|
||||
/// Wrapper around sqlite3_db_config() which is a variadic function that can't
|
||||
/// be used from Swift.
|
||||
static inline void _disableDoubleQuotedStringLiterals(sqlite3 *db) {
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 0, (void *)0);
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 0, (void *)0);
|
||||
}
|
||||
|
||||
/// Wrapper around sqlite3_db_config() which is a variadic function that can't
|
||||
/// be used from Swift.
|
||||
static inline void _enableDoubleQuotedStringLiterals(sqlite3 *db) {
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 1, (void *)0);
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 1, (void *)0);
|
||||
}
|
||||
#else
|
||||
static inline void _disableDoubleQuotedStringLiterals(sqlite3 *db) { }
|
||||
static inline void _enableDoubleQuotedStringLiterals(sqlite3 *db) { }
|
||||
#endif
|
||||
#endif /* grdb_config_h */
|
||||
@@ -0,0 +1,4 @@
|
||||
module GRDBSQLCipher {
|
||||
header "SQLCipher_config.h"
|
||||
export *
|
||||
}
|
||||
Reference in new issue
Block a user