Skip to content

Commit c82f986

Browse files
committed
Merge pull request #431 from jberkel/sqlite3-subspec
CocoaPods: build standalone version of SQLite with subspec
2 parents d93f37b + c29ec30 commit c82f986

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

Documentation/Index.md

+18
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,26 @@ install SQLite.swift with Carthage:
111111
112112
3. Run `pod install`.
113113
114+
#### Requiring a specific version of SQLite
115+
116+
If you want to use a more recent version of SQLite than what is provided with the OS you can require the `standalone` subspec:
117+
118+
``` ruby
119+
pod 'SQLite.swift/standalone', '~> 0.10.1'
120+
```
121+
122+
By default this will use the most recent version of SQLite without any extras. If you want you can further customize this by adding another dependency to sqlite3 or one of its subspecs:
123+
124+
``` ruby
125+
pod 'SQLite.swift/standalone', '~> 0.10.1'
126+
pod 'sqlite3/fts5', '= 3.11.1' # SQLite 3.11.1 with FTS5 enabled
127+
```
128+
129+
See the [sqlite3 podspec][sqlite3pod] for more details.
130+
114131
[CocoaPods]: https://cocoapods.org
115132
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started
133+
[sqlite3pod]: https://github.com/clemensg/sqlite3pod
116134

117135

118136
### Manual

SQLite.swift.podspec

+25-14
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,30 @@ Pod::Spec.new do |s|
2424
s.tvos.deployment_target = "9.0"
2525
s.osx.deployment_target = "10.9"
2626
s.watchos.deployment_target = "2.0"
27+
s.default_subspec = 'standard'
2728

28-
s.preserve_paths = 'CocoaPods/**/*'
29-
s.pod_target_xcconfig = {
30-
'SWIFT_INCLUDE_PATHS[sdk=macosx*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/macosx',
31-
'SWIFT_INCLUDE_PATHS[sdk=iphoneos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/iphoneos',
32-
'SWIFT_INCLUDE_PATHS[sdk=iphonesimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/iphonesimulator',
33-
'SWIFT_INCLUDE_PATHS[sdk=appletvos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/appletvos',
34-
'SWIFT_INCLUDE_PATHS[sdk=appletvsimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/appletvsimulator',
35-
'SWIFT_INCLUDE_PATHS[sdk=watchos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/watchos',
36-
'SWIFT_INCLUDE_PATHS[sdk=watchsimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/watchsimulator'
37-
}
38-
39-
s.libraries = 'sqlite3'
40-
s.source_files = 'SQLite/**/*.{c,h,m,swift}'
41-
s.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
29+
s.subspec 'standard' do |ss|
30+
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
31+
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
32+
33+
ss.library = 'sqlite3'
34+
ss.preserve_paths = 'CocoaPods/**/*'
35+
ss.pod_target_xcconfig = {
36+
'SWIFT_INCLUDE_PATHS[sdk=macosx*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/macosx',
37+
'SWIFT_INCLUDE_PATHS[sdk=iphoneos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/iphoneos',
38+
'SWIFT_INCLUDE_PATHS[sdk=iphonesimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/iphonesimulator',
39+
'SWIFT_INCLUDE_PATHS[sdk=appletvos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/appletvos',
40+
'SWIFT_INCLUDE_PATHS[sdk=appletvsimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/appletvsimulator',
41+
'SWIFT_INCLUDE_PATHS[sdk=watchos*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/watchos',
42+
'SWIFT_INCLUDE_PATHS[sdk=watchsimulator*]' => '$(SRCROOT)/SQLite.swift/CocoaPods/watchsimulator'
43+
}
44+
end
45+
46+
s.subspec 'standalone' do |ss|
47+
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
48+
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
49+
ss.xcconfig = { 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_STANDALONE' }
50+
51+
ss.dependency 'sqlite3'
52+
end
4253
end

SQLite/Core/Connection.swift

+4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
//
2424

2525
import Dispatch
26+
#if SQLITE_SWIFT_STANDALONE
27+
import sqlite3
28+
#else
2629
import CSQLite
30+
#endif
2731

2832
/// A connection to SQLite.
2933
public final class Connection {

SQLite/Core/Statement.swift

+4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
// THE SOFTWARE.
2323
//
2424

25+
#if SQLITE_SWIFT_STANDALONE
26+
import sqlite3
27+
#else
2528
import CSQLite
29+
#endif
2630

2731
/// A single SQL statement.
2832
public final class Statement {

SQLite/Helpers.swift

+4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
// THE SOFTWARE.
2323
//
2424

25+
#if SQLITE_SWIFT_STANDALONE
26+
import sqlite3
27+
#else
2528
import CSQLite
29+
#endif
2630

2731
public typealias Star = (Expression<Binding>?, Expression<Binding>?) -> Expression<Void>
2832

0 commit comments

Comments
 (0)