Skip to content

Commit ceaec3e

Browse files
authored
Merge pull request stephencelis#560 from stephencelis/package-manager
Swift Package Manager
2 parents 440516d + 3656d9e commit ceaec3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+104
-66
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ DerivedData
2121

2222
# Carthage
2323
Carthage
24+
25+
# Swift Package Manager
26+
.build
27+
Packages/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ matrix:
1212
- env: VALIDATOR_SUBSPEC="standard"
1313
- env: VALIDATOR_SUBSPEC="standalone"
1414
- env: VALIDATOR_SUBSPEC="SQLCipher"
15+
- env: PACKAGE_MANAGER_COMMAND="test -Xlinker -lsqlite3"
1516
before_install:
1617
- gem update bundler
1718
- gem install xcpretty --no-document

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
========================================
33

44
* Fixed SQLCipher integration with read-only databases ([#559][])
5+
* Preliminary Swift Package Manager support ([#548][], [#560][])
56
* Fixed null pointer when fetching an empty BLOB ([#561][])
67

78
0.11.1 (06-12-2016), [diff][diff-0.11.1]
@@ -24,6 +25,8 @@
2425

2526
[#532]: https://github.com/stephencelis/SQLite.swift/issues/532
2627
[#546]: https://github.com/stephencelis/SQLite.swift/issues/546
28+
[#548]: https://github.com/stephencelis/SQLite.swift/pull/548
2729
[#553]: https://github.com/stephencelis/SQLite.swift/pull/553
2830
[#559]: https://github.com/stephencelis/SQLite.swift/pull/559
31+
[#560]: https://github.com/stephencelis/SQLite.swift/pull/560
2932
[#561]: https://github.com/stephencelis/SQLite.swift/issues/561

CocoaPodsTests/integration_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_validate_project
1313

1414
def validator
1515
@validator ||= TestRunningValidator.new(podspec, []).tap do |validator|
16-
validator.test_files = Dir["#{project_test_dir}/*.swift"]
16+
validator.test_files = Dir["#{project_test_dir}/**/*.swift"]
1717
validator.test_resources = Dir["#{project_test_dir}/fixtures"]
1818
validator.config.verbose = true
1919
validator.no_clean = true
@@ -38,6 +38,6 @@ def podspec
3838
end
3939

4040
def project_test_dir
41-
File.expand_path(File.dirname(__FILE__) + '/../SQLiteTests')
41+
File.expand_path(File.dirname(__FILE__) + '/../Tests/SQLiteTests')
4242
end
4343
end

Documentation/Index.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
- [Installation](#installation)
44
- [Carthage](#carthage)
55
- [CocoaPods](#cocoapods)
6+
- [Swift Package Manager](#swift-package-manager)
67
- [Manual](#manual)
7-
- [Frameworkless Targets](#frameworkless-targets)
88
- [Getting Started](#getting-started)
99
- [Connecting to a Database](#connecting-to-a-database)
1010
- [Read-Write Databases](#read-write-databases)
@@ -162,6 +162,30 @@ try db.rekey("another secret")
162162
[sqlite3pod]: https://github.com/clemensg/sqlite3pod
163163
[SQLCipher]: https://www.zetetic.net/sqlcipher/
164164

165+
### Swift Package Manager
166+
167+
The [Swift Package Manager][] is a tool for managing the distribution of Swift code.
168+
It’s integrated with the Swift build system to automate the process of
169+
downloading, compiling, and linking dependencies.
170+
171+
It is the recommended approach for using SQLite.swift in OSX CLI applications.
172+
173+
1. Add the following to your `Package.swift` file:
174+
175+
``` swift
176+
dependencies: [
177+
.Package(url: "https://github.com/stephencelis/SQLite.swift.git", majorVersion: 0, minor: 11)
178+
]
179+
```
180+
181+
2. Build your project:
182+
183+
``` sh
184+
$ swift build -Xlinker -lsqlite3
185+
```
186+
187+
[Swift Package Manager]: https://swift.org/package-manager
188+
165189
### Manual
166190

167191
To install SQLite.swift as an Xcode sub-project:
@@ -186,24 +210,6 @@ Some additional steps are required to install the application on an actual devic
186210

187211
7. **Add**.
188212

189-
### Frameworkless Targets
190-
191-
It’s possible to use SQLite.swift in a target that doesn’t support frameworks, including iOS 7 apps and OS X command line tools, though it takes a little extra work.
192-
193-
1. In your target’s **Build Phases**, add **libsqlite3.dylib** to the **Link Binary With Libraries** build phase.
194-
195-
2. Copy the SQLite.swift source files (from its **SQLite** directory) into your Xcode project.
196-
197-
3. Add the following lines to your project’s [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_79) (a file usually in the form of `$(TARGET_NAME)-Bridging-Header.h`).
198-
199-
``` swift
200-
#import <sqlite3.h>
201-
#import "SQLite-Bridging.h"
202-
```
203-
204-
> _Note:_ Adding SQLite.swift source files directly to your application will both remove the `SQLite` module namespace (no need—or ability—to `import SQLite`) and expose internal functions and variables. You will need to rename anything that conflicts with code of your own. Please [report any bugs](https://github.com/stephencelis/SQLite.swift/issues/new) (_e.g._, segfaults) you encounter.
205-
206-
207213
## Getting Started
208214

209215
To use SQLite.swift classes or structures in your target’s source file, first import the `SQLite` module.

Documentation/Planning.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@ _Lists agreed upon next steps in approximate priority order._
1111

1212
_A gathering point for ideas for new features. In general, the corresponding issue will be closed once it is added here, with the assumption that it will be referred to when it comes time to add the corresponding feature._
1313

14-
### Packaging
15-
16-
* linux support via Swift Package Manager, per [#315](https://github.com/stephencelis/SQLite.swift/issues/315), _in progress_: [#548](https://github.com/stephencelis/SQLite.swift/pull/548)
17-
1814
### Features
1915

2016
* encapsulate ATTACH DATABASE / DETACH DATABASE as methods, per [#30](https://github.com/stephencelis/SQLite.swift/issues/30)
2117
* provide separate threads for update vs read, so updates don't block reads, per [#236](https://github.com/stephencelis/SQLite.swift/issues/236)
22-
* expose more FTS4 options, e.g. virtual table support per [#164](https://github.com/stephencelis/SQLite.swift/issues/164)
2318
* expose triggers, per [#164](https://github.com/stephencelis/SQLite.swift/issues/164)
2419

2520
## Suspended Feature Requests

Package.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "SQLite",
5+
targets: [
6+
Target(
7+
name: "SQLite",
8+
dependencies: [
9+
.Target(name: "SQLiteObjc")
10+
]),
11+
Target(name: "SQLiteObjc")
12+
],
13+
dependencies: [
14+
.Package(url: "https://github.com/jberkel/CSQLite.git", majorVersion: 0)
15+
]
16+
)

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ For a more comprehensive example, see [this article](http://masteringswift.blogs
112112
> _Note:_ SQLite.swift requires Swift 3 (and [Xcode][] 8) or greater. If you absolutely
113113
> need compatibility with Swift 2.3 you can use the [swift-2.3][] branch or older
114114
> released versions. New development will happen exclusively on the master/Swift 3 branch.
115-
>
116-
> The following instructions apply to targets that support embedded
117-
> Swift frameworks. To use SQLite.swift in iOS 7 or an OS X command line
118-
> tool, please read the [Frameworkless Targets][] section of the
119-
> documentation.
120-
121115
122116
### Carthage
123117

@@ -174,6 +168,19 @@ SQLite.swift with CocoaPods:
174168
[CocoaPods]: https://cocoapods.org
175169
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started
176170
171+
### Swift Package Manager
172+
173+
The [Swift Package Manager][] is a tool for managing the distribution of Swift code.
174+
175+
1. Add the following to your `Package.swift` file:
176+
177+
```swift
178+
dependencies: [
179+
.Package(url: "https://github.com/stephencelis/SQLite.swift.git", majorVersion: 0, minor: 11)
180+
]
181+
```
182+
183+
[Swift Package Manager]: https://swift.org/package-manager
177184

178185
### Manual
179186

@@ -200,7 +207,6 @@ Some additional steps are required to install the application on an actual devic
200207
7. **Add**.
201208

202209

203-
[Frameworkless Targets]: Documentation/Index.md#frameworkless-targets
204210
[Xcode]: https://developer.apple.com/xcode/downloads/
205211
[Submodule]: http://git-scm.com/book/en/Git-Tools-Submodules
206212
[download]: https://github.com/stephencelis/SQLite.swift/archive/master.zip

SQLite.swift.podspec

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Pod::Spec.new do |s|
2525
}
2626

2727
s.subspec 'standard' do |ss|
28-
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
29-
ss.exclude_files = 'SQLite/Extensions/Cipher.swift'
30-
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
28+
ss.source_files = 'Sources/{SQLite,SQLiteObjc}/**/*.{c,h,m,swift}'
29+
ss.exclude_files = 'Sources/**/Cipher.swift'
30+
ss.private_header_files = 'Sources/SQLiteObjc/*.h'
3131

3232
ss.library = 'sqlite3'
3333
ss.preserve_paths = 'CocoaPods/**/*'
@@ -47,9 +47,9 @@ Pod::Spec.new do |s|
4747
end
4848

4949
s.subspec 'standalone' do |ss|
50-
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
51-
ss.exclude_files = 'SQLite/Extensions/Cipher.swift'
52-
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
50+
ss.source_files = 'Sources/{SQLite,SQLiteObjc}/**/*.{c,h,m,swift}'
51+
ss.exclude_files = 'Sources/**/Cipher.swift'
52+
ss.private_header_files = 'Sources/SQLiteObjc/*.h'
5353
ss.xcconfig = {
5454
'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_STANDALONE'
5555
}
@@ -58,8 +58,8 @@ Pod::Spec.new do |s|
5858
end
5959

6060
s.subspec 'SQLCipher' do |ss|
61-
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
62-
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
61+
ss.source_files = 'Sources/{SQLite,SQLiteObjc}/**/*.{c,h,m,swift}'
62+
ss.private_header_files = 'Sources/SQLiteObjc/*.h'
6363
ss.xcconfig = {
6464
'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_SQLCIPHER',
6565
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1'

0 commit comments

Comments
 (0)