From a5c1361dc980d07ccb1d1f383ea4bba60c87f237 Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Sat, 13 May 2017 22:49:14 +0200 Subject: [PATCH 1/7] Add Support for SQLCipher in CocoaPods --- GRDB.swift.podspec | 18 +++++++++++++++++- Support/GRDB.h | 7 ++++++- Support/grdb_config.c | 7 ++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index ee1374c2c..d42985976 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -13,8 +13,24 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' s.watchos.deployment_target = '2.0' - s.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' s.module_map = 'Support/module.modulemap' s.framework = 'Foundation' s.library = 'sqlite3' + s.default_subspec = 'standard' + + s.subspec 'standard' do |ss| + ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' + end + + s.subspec 'SQLCipher' do |ss| + ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' + ss.exclude_files = 'Support/sqlite3.h' + ss.xcconfig = { + 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_BUILTIN_SQLITE -DUSING_SQLCIPHER', + 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1' + } + + ss.dependency 'SQLCipher', '>= 3.4.0' + end end diff --git a/Support/GRDB.h b/Support/GRDB.h index 2bd4d1b5d..c0913a578 100644 --- a/Support/GRDB.h +++ b/Support/GRDB.h @@ -7,4 +7,9 @@ FOUNDATION_EXPORT double GRDB_VersionNumber; FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #import -#import + +#if SQLITE_HAS_CODEC + #import +#else + #import +#endif diff --git a/Support/grdb_config.c b/Support/grdb_config.c index d68ef20b5..108e4cd43 100644 --- a/Support/grdb_config.c +++ b/Support/grdb_config.c @@ -1,5 +1,10 @@ #include -#include +#if SQLITE_HAS_CODEC + #include +#else + #include +#endif + void registerErrorLogCallback(errorLogCallback callback) { sqlite3_config(SQLITE_CONFIG_LOG, callback, 0); From 64df5c6b41f9f76e3346998c2d524be585a0a4a5 Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Sat, 13 May 2017 22:54:56 +0200 Subject: [PATCH 2/7] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c016228f1..48c57ed9c 100644 --- a/README.md +++ b/README.md @@ -4579,7 +4579,12 @@ try controller.performFetch() **GRDB can encrypt your database with [SQLCipher](http://sqlcipher.net) v3.4.0.** -This requires a manual installation of GRDB: +Using CocoaPods +```ruby +pod 'GRDB.swift/SQLCipher' +``` + +Using a manual installation of GRDB: 1. Clone the GRDB.swift git repository, checkout the latest tagged version, and download SQLCipher sources: @@ -4587,7 +4592,7 @@ This requires a manual installation of GRDB: cd [GRDB.swift directory] git checkout v0.107.0 git submodule update --init SQLCipher/src - ```` + ``` 2. Embed the `GRDB.xcodeproj` project in your own project. @@ -4595,11 +4600,12 @@ This requires a manual installation of GRDB: 4. Add the `GRDBCipher.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your target. +5. Import `GRDBCipher` module in your project's files + + **You create and open an encrypted database** by providing a passphrase to your [database connection](#database-connections): ```swift -import GRDBCipher - var configuration = Configuration() configuration.passphrase = "secret" let dbQueue = try DatabaseQueue(path: "...", configuration: configuration) From 7c8b48e08aecd32a3e30c37fd3c2da8713128bf0 Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Sun, 14 May 2017 14:44:11 +0200 Subject: [PATCH 3/7] Fix Podspec --- GRDB.swift.podspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index d42985976..db29b7bc5 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -15,18 +15,18 @@ Pod::Spec.new do |s| s.module_map = 'Support/module.modulemap' s.framework = 'Foundation' - s.library = 'sqlite3' - s.default_subspec = 'standard' + s.default_subspec = 'default' - s.subspec 'standard' do |ss| + s.subspec 'default' do |ss| ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' + ss.library = 'sqlite3' end s.subspec 'SQLCipher' do |ss| ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' ss.exclude_files = 'Support/sqlite3.h' ss.xcconfig = { - 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_BUILTIN_SQLITE -DUSING_SQLCIPHER', + 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_SQLCIPHER', 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1' } From b1cdd1360b6ba412c2b36d2398721a31a85d1eca Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Wed, 17 May 2017 01:17:10 +0200 Subject: [PATCH 4/7] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48c57ed9c..23c545867 100644 --- a/README.md +++ b/README.md @@ -4579,7 +4579,8 @@ try controller.performFetch() **GRDB can encrypt your database with [SQLCipher](http://sqlcipher.net) v3.4.0.** -Using CocoaPods +Using CocoaPods: + ```ruby pod 'GRDB.swift/SQLCipher' ``` From c66c0a11b63cd39c94a05d8e2a0e07ce3a280db3 Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Wed, 17 May 2017 01:29:28 +0200 Subject: [PATCH 5/7] Add Cocoapods checks for SQLCipher subspec --- Support/GRDB.h | 2 +- Support/grdb_config.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Support/GRDB.h b/Support/GRDB.h index c0913a578..2f7dc1257 100644 --- a/Support/GRDB.h +++ b/Support/GRDB.h @@ -8,7 +8,7 @@ FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #import -#if SQLITE_HAS_CODEC +#if SQLITE_HAS_CODEC && defined(COCOAPODS) #import #else #import diff --git a/Support/grdb_config.c b/Support/grdb_config.c index 108e4cd43..6273ad34d 100644 --- a/Support/grdb_config.c +++ b/Support/grdb_config.c @@ -1,5 +1,5 @@ #include -#if SQLITE_HAS_CODEC +#if SQLITE_HAS_CODEC && defined(COCOAPODS) #include #else #include From f1a9cdaa8efc9bbe0f027b53cb61a3ce4656b45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 17 May 2017 13:27:03 +0200 Subject: [PATCH 6/7] Restore GRDB.swift.podspec, introduce GRDBCipher.podspec --- GRDB.swift.podspec | 20 ++------------------ GRDBCipher.podspec | 25 +++++++++++++++++++++++++ SQLCipher/GRDBCipher.h | 6 +++++- Support/GRDB.h | 7 +------ Support/grdb_config.c | 5 +++-- 5 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 GRDBCipher.podspec diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index db29b7bc5..ee1374c2c 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -13,24 +13,8 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' s.watchos.deployment_target = '2.0' + s.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' s.module_map = 'Support/module.modulemap' s.framework = 'Foundation' - s.default_subspec = 'default' - - s.subspec 'default' do |ss| - ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' - ss.library = 'sqlite3' - end - - s.subspec 'SQLCipher' do |ss| - ss.source_files = 'GRDB/**/*.swift', 'Support/*.{c,h}' - ss.exclude_files = 'Support/sqlite3.h' - ss.xcconfig = { - 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_SQLCIPHER', - 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC', - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1' - } - - ss.dependency 'SQLCipher', '>= 3.4.0' - end + s.library = 'sqlite3' end diff --git a/GRDBCipher.podspec b/GRDBCipher.podspec new file mode 100644 index 000000000..77b0ae533 --- /dev/null +++ b/GRDBCipher.podspec @@ -0,0 +1,25 @@ +Pod::Spec.new do |s| + s.name = 'GRDBCipher' + s.version = '0.107.0' + + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.summary = 'A Swift application toolkit for SQLite databases.' + s.homepage = 'https://github.com/groue/GRDB.swift' + s.author = { 'Gwendal Roué' => 'gr@pierlis.com' } + s.source = { :git => 'https://github.com/groue/GRDB.swift.git', :tag => "v#{s.version}" } + s.module_name = 'GRDBCipher' + + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.9' + s.watchos.deployment_target = '2.0' + + s.source_files = 'GRDB/**/*.swift', 'SQLCipher/*.h', 'Support/grdb_config.{c,h}' + s.module_map = 'SQLCipher/module.modulemap' + s.xcconfig = { + 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_SQLCIPHER', + 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DUSING_SQLCIPHER', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1' + } + s.framework = 'Foundation' + s.dependency 'SQLCipher', '~> 3.4.0' +end diff --git a/SQLCipher/GRDBCipher.h b/SQLCipher/GRDBCipher.h index dda719bde..82d9edb59 100644 --- a/SQLCipher/GRDBCipher.h +++ b/SQLCipher/GRDBCipher.h @@ -8,4 +8,8 @@ FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #define SQLITE_HAS_CODEC #import -#import +#ifdef COCOAPODS + #import +#else + #import +#endif diff --git a/Support/GRDB.h b/Support/GRDB.h index 2f7dc1257..2bd4d1b5d 100644 --- a/Support/GRDB.h +++ b/Support/GRDB.h @@ -7,9 +7,4 @@ FOUNDATION_EXPORT double GRDB_VersionNumber; FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; #import - -#if SQLITE_HAS_CODEC && defined(COCOAPODS) - #import -#else - #import -#endif +#import diff --git a/Support/grdb_config.c b/Support/grdb_config.c index 6273ad34d..3a75f975c 100644 --- a/Support/grdb_config.c +++ b/Support/grdb_config.c @@ -1,7 +1,8 @@ -#include -#if SQLITE_HAS_CODEC && defined(COCOAPODS) +#if USING_SQLCIPHER && defined(COCOAPODS) + #include #include #else + #include #include #endif From 798588c54b8fdc481dfd36a6633395a693cc32f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 17 May 2017 14:19:31 +0200 Subject: [PATCH 7/7] Documentation for GRDBCipher installation via CocoaPods --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23c545867..daa15635d 100644 --- a/README.md +++ b/README.md @@ -4579,13 +4579,14 @@ try controller.performFetch() **GRDB can encrypt your database with [SQLCipher](http://sqlcipher.net) v3.4.0.** -Using CocoaPods: +You can use [CocoaPods](http://cocoapods.org/) (version 1.1 or higher), and specify in your `Podfile`: ```ruby -pod 'GRDB.swift/SQLCipher' +use_frameworks! +pod 'GRDBCipher' ``` -Using a manual installation of GRDB: +Alternatively, perform a manual installation of GRDB and SQLCipher: 1. Clone the GRDB.swift git repository, checkout the latest tagged version, and download SQLCipher sources: @@ -4601,12 +4602,12 @@ Using a manual installation of GRDB: 4. Add the `GRDBCipher.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your target. -5. Import `GRDBCipher` module in your project's files - **You create and open an encrypted database** by providing a passphrase to your [database connection](#database-connections): ```swift +import GRDBCipher + var configuration = Configuration() configuration.passphrase = "secret" let dbQueue = try DatabaseQueue(path: "...", configuration: configuration)