SQLCipher.swift is based on SQLCipher Core and is the official Swift Package for SQLCipher maintained by Zetetic, LLC.
SQLCipher is a standalone fork of the SQLite database library that adds 256 bit AES encryption of database files and other security features like:
- on-the-fly encryption
- tamper detection
- memory sanitization
- strong key derivation
Xcode
- In Xcode go to File > Add Packages...
- Enter the repository URL:
https://github.com/sqlcipher/sqlcipher-spm
- Choose your desired version or branch.
Package Dependency
- Add the following to your
Package.swift
file:
dependencies: [
.package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.10.0")
]
- Build your project:
$ swift build
For Swift based projects, import the SQLCipher module using import SQLCipher
For Objective-C based projets, import the SQLCipher module using #import <SQLCipher/SQLCipher.h>
To enable SQLCipher encryption in your consuming project, you must set the SQLITE_HAS_CODEC
Build Setting flag.
For Swift based projects, go to your project's Build Settings and search for Preprocessor Macros, enter SQLITE_HAS_CODEC=1
for both Debug and Release Preprocessor Macros.
For Objective-C based projects, go to your project's Build Settings and search for Other C Flags, enter -DSQITE_HAS_CODEC
for both Debug and Release Other C Flags.
SQLCipher.swift is distributed under a BSD-style license, requiring attribution and reproduction of the license in applications and documentation. See the the LICENSE file for more information.
The primary source for complete documentation (design, API, platforms, usage) is the SQLCipher website:
https://www.zetetic.net/sqlcipher/documentation
The primary avenue for support and discussions is the SQLCipher discuss site:
https://discuss.zetetic.net/c/sqlcipher
Issues or support questions on using SQLCipher should be entered into the GitHub Issue tracker:
https://github.com/sqlcipher/SQLCipher.swift/issues
Please DO NOT post issues, support questions, or other problems to blog posts about SQLCipher as we do not monitor them frequently.
If you are using SQLCipher in your own software please let us know at [email protected]!
SQLCipher commercial libraries are available for purchase which have some signficant advantages:
- Easier to setup, saving many steps in project configuration
- Value Level Encryption
- Encrypted Virtual Tables
- Performance Counters & Statistics
- Private Priority Support from SQLCipher developers