Skip to content

Swift Package Manager #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ DerivedData

# Carthage
Carthage

# Swift Package Manager
.build
Packages/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ matrix:
- env: VALIDATOR_SUBSPEC="standard"
- env: VALIDATOR_SUBSPEC="standalone"
- env: VALIDATOR_SUBSPEC="SQLCipher"
- env: PACKAGE_MANAGER_COMMAND="test -Xlinker -lsqlite3"
before_install:
- gem update bundler
- gem install xcpretty --no-document
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
========================================

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

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

[#532]: https://github.com/stephencelis/SQLite.swift/issues/532
[#546]: https://github.com/stephencelis/SQLite.swift/issues/546
[#548]: https://github.com/stephencelis/SQLite.swift/pull/548
[#553]: https://github.com/stephencelis/SQLite.swift/pull/553
[#559]: https://github.com/stephencelis/SQLite.swift/pull/559
[#560]: https://github.com/stephencelis/SQLite.swift/pull/560
[#561]: https://github.com/stephencelis/SQLite.swift/issues/561
4 changes: 2 additions & 2 deletions CocoaPodsTests/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_validate_project

def validator
@validator ||= TestRunningValidator.new(podspec, []).tap do |validator|
validator.test_files = Dir["#{project_test_dir}/*.swift"]
validator.test_files = Dir["#{project_test_dir}/**/*.swift"]
validator.test_resources = Dir["#{project_test_dir}/fixtures"]
validator.config.verbose = true
validator.no_clean = true
Expand All @@ -38,6 +38,6 @@ def podspec
end

def project_test_dir
File.expand_path(File.dirname(__FILE__) + '/../SQLiteTests')
File.expand_path(File.dirname(__FILE__) + '/../Tests/SQLiteTests')
end
end
44 changes: 25 additions & 19 deletions Documentation/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- [Installation](#installation)
- [Carthage](#carthage)
- [CocoaPods](#cocoapods)
- [Swift Package Manager](#swift-package-manager)
- [Manual](#manual)
- [Frameworkless Targets](#frameworkless-targets)
- [Getting Started](#getting-started)
- [Connecting to a Database](#connecting-to-a-database)
- [Read-Write Databases](#read-write-databases)
Expand Down Expand Up @@ -162,6 +162,30 @@ try db.rekey("another secret")
[sqlite3pod]: https://github.com/clemensg/sqlite3pod
[SQLCipher]: https://www.zetetic.net/sqlcipher/

### Swift Package Manager

The [Swift Package Manager][] is a tool for managing the distribution of Swift code.
It’s integrated with the Swift build system to automate the process of
downloading, compiling, and linking dependencies.

It is the recommended approach for using SQLite.swift in OSX CLI applications.

1. Add the following to your `Package.swift` file:

``` swift
dependencies: [
.Package(url: "https://github.com/stephencelis/SQLite.swift.git", majorVersion: 0, minor: 11)
]
```

2. Build your project:

``` sh
$ swift build -Xlinker -lsqlite3
```

[Swift Package Manager]: https://swift.org/package-manager

### Manual

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

7. **Add**.

### Frameworkless Targets

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.

1. In your target’s **Build Phases**, add **libsqlite3.dylib** to the **Link Binary With Libraries** build phase.

2. Copy the SQLite.swift source files (from its **SQLite** directory) into your Xcode project.

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`).

``` swift
#import <sqlite3.h>
#import "SQLite-Bridging.h"
```

> _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.


## Getting Started

To use SQLite.swift classes or structures in your target’s source file, first import the `SQLite` module.
Expand Down
5 changes: 0 additions & 5 deletions Documentation/Planning.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ _Lists agreed upon next steps in approximate priority order._

_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._

### Packaging

* 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)

### Features

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

## Suspended Feature Requests
Expand Down
16 changes: 16 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PackageDescription

let package = Package(
name: "SQLite",
targets: [
Target(
name: "SQLite",
dependencies: [
.Target(name: "SQLiteObjc")
]),
Target(name: "SQLiteObjc")
],
dependencies: [
.Package(url: "https://github.com/jberkel/CSQLite.git", majorVersion: 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephencelis this should probably be moved to your namespace – I couldn't find a way to avoid a separate repository. there's something like dependency pinning now but it seems to be a newer feature, it's not on my system.

]
)
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ For a more comprehensive example, see [this article](http://masteringswift.blogs
> _Note:_ SQLite.swift requires Swift 3 (and [Xcode][] 8) or greater. If you absolutely
> need compatibility with Swift 2.3 you can use the [swift-2.3][] branch or older
> released versions. New development will happen exclusively on the master/Swift 3 branch.
>
> The following instructions apply to targets that support embedded
> Swift frameworks. To use SQLite.swift in iOS 7 or an OS X command line
> tool, please read the [Frameworkless Targets][] section of the
> documentation.


### Carthage

Expand Down Expand Up @@ -174,6 +168,19 @@ SQLite.swift with CocoaPods:
[CocoaPods]: https://cocoapods.org
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started

### Swift Package Manager

The [Swift Package Manager][] is a tool for managing the distribution of Swift code.

1. Add the following to your `Package.swift` file:

```swift
dependencies: [
.Package(url: "https://github.com/stephencelis/SQLite.swift.git", majorVersion: 0, minor: 11)
]
```

[Swift Package Manager]: https://swift.org/package-manager

### Manual

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


[Frameworkless Targets]: Documentation/Index.md#frameworkless-targets
[Xcode]: https://developer.apple.com/xcode/downloads/
[Submodule]: http://git-scm.com/book/en/Git-Tools-Submodules
[download]: https://github.com/stephencelis/SQLite.swift/archive/master.zip
Expand Down
16 changes: 8 additions & 8 deletions SQLite.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Pod::Spec.new do |s|
}

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

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

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

s.subspec 'SQLCipher' do |ss|
ss.source_files = 'SQLite/**/*.{c,h,m,swift}'
ss.private_header_files = 'SQLite/Core/fts3_tokenizer.h'
ss.source_files = 'Sources/{SQLite,SQLiteObjc}/**/*.{c,h,m,swift}'
ss.private_header_files = 'Sources/SQLiteObjc/*.h'
ss.xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_SQLCIPHER',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1'
Expand Down
Loading