Skip to content

Commit e125805

Browse files
committed
SQLCipher CocoaPods support
Using a sub-spec, it's easy to use SQLCipher, as well: pod 'SQLite.swift/Cipher', git: # ... Signed-off-by: Stephen Celis <stephen@stephencelis.com>
1 parent 9bfae5c commit e125805

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

Documentation/Index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
``` ruby
8080
use_frameworks!
8181
pod 'SQLite.swift', git: 'https://github.com/stephencelis/SQLite.swift.git'
82+
# pod 'SQLite.swift/Cipher', git: ... # instead, for SQLCipher support
8283
```
8384

8485
3. Run `pod install`.
@@ -104,13 +105,13 @@ To install SQLite.swift as an Xcode sub-project:
104105
You should now be able to `import SQLite` from any of your target’s source files and begin using SQLite.swift.
105106

106107

107-
### SQLCipher
108+
#### SQLCipher
108109

109110
To install SQLite.swift with [SQLCipher](http://sqlcipher.net) support:
110111

111112
1. Make sure the **sqlcipher** working copy is checked out in Xcode. If **sqlcipher.xcodeproj** is unavailable (_i.e._, it appears red), go to the **Source Control** menu and select **Check Out sqlcipher…** from the **sqlcipher** menu item.
112113

113-
2. Follow [the instructions above](#installation) with the **SQLiteCipher** target, instead.
114+
2. Follow [the instructions above](#manual) with the **SQLiteCipher** target, instead.
114115

115116
> _Note:_ By default, SQLCipher compiles [without support for full-text search](https://github.com/sqlcipher/sqlcipher/issues/102). If you intend to use [FTS4](#full-text-search), make sure you add the following to **Other C Flags** in the **Build Settings** of the **sqlcipher** target (in the **sqlcipher.xcodeproj** project):
116117
>

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,18 @@ interactively, from the Xcode project’s playground.
119119
[CocoaPods][] is a dependency manager for Cocoa projects. To install
120120
SQLite.swift with CocoaPods:
121121

122-
1. Make sure CocoaPods is [installed][CocoaPods Installation] (SQLite.swift
123-
requires version 0.37 or greater).
122+
1. Make sure CocoaPods is [installed][CocoaPods Installation] (SQLite.swift
123+
requires version 0.37 or greater).
124124

125-
2. Update your Podfile to include the following:
125+
2. Update your Podfile to include the following:
126126

127-
``` ruby
128-
use_frameworks!
129-
pod 'SQLite.swift', git: 'https://github.com/stephencelis/SQLite.swift.git'
130-
```
127+
``` ruby
128+
use_frameworks!
129+
pod 'SQLite.swift', git: 'https://github.com/stephencelis/SQLite.swift.git'
130+
# pod 'SQLite.swift/Cipher', git: ... # instead, for SQLCipher support
131+
```
131132

132-
3. Run `pod install`.
133+
3. Run `pod install`.
133134

134135
[CocoaPods]: https://cocoapods.org
135136
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started
@@ -168,8 +169,8 @@ To install SQLite.swift with [SQLCipher][] support:
168169
**Source Control** menu and select **Check Out sqlcipher…** from the
169170
**sqlcipher** menu item.
170171

171-
2. Follow [the instructions above](#installation) with the
172-
**SQLiteCipher** target, instead.
172+
2. Follow [the instructions above](#manual) with the **SQLiteCipher** target,
173+
instead.
173174

174175
> _Note:_ By default, SQLCipher compiles [without support for full-text
175176
> search][]. If you intend to use [FTS4][], make sure you add the

SQLite.swift.podspec

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,34 @@ Pod::Spec.new do |s|
1515
s.author = { 'Stephen Celis' => 'stephen@stephencelis.com' }
1616
s.social_media_url = 'https://twitter.com/stephencelis'
1717

18-
s.library = 'sqlite3'
19-
2018
s.source = {
2119
git: 'https://github.com/stephencelis/SQLite.swift.git',
2220
tag: s.version
2321
}
2422

25-
s.source_files = 'SQLite/**/*.{swift,c,h,m}'
26-
s.private_header_files = 'SQLite/fts3_tokenizer.h'
27-
2823
s.module_map = 'SQLite/module.modulemap'
24+
25+
s.default_subspec = 'Library'
26+
27+
s.subspec 'Core' do |ss|
28+
ss.source_files = 'SQLite/**/*.{swift,c,h,m}'
29+
ss.private_header_files = 'SQLite/fts3_tokenizer.h'
30+
end
31+
32+
s.subspec 'Library' do |ss|
33+
ss.dependency 'SQLite.swift/Core'
34+
35+
ss.library = 'sqlite3'
36+
end
37+
38+
s.subspec 'Cipher' do |ss|
39+
ss.dependency 'SQLCipher'
40+
ss.dependency 'SQLite.swift/Core'
41+
42+
ss.source_files = 'SQLiteCipher/**/*.{swift,c,h,m}'
43+
44+
ss.xcconfig = {
45+
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1'
46+
}
47+
end
2948
end

0 commit comments

Comments
 (0)