SQLCipher Swift Package for Apple - Third Party Integrators

Community Edition Feature

SQLCipher Swift Package provides developers a quick and easy way to add industry leading secure encryption to Apple projects which use SQLite databases.

The SQLCipher Swift package is maintained by the developers of SQLCipher so there are several benefits to using it as a Swift Package author:

  • As the "official" Swift Package for SQLCipher, it's maintained directly by the SQLCipher development team. This avoids trusting semi-anonymous third parties for SQLCipher Swift packages.
  • We guarantee it will be updated immediately with every release release of SQLCipher. This eliminates the risk of relying on out-dated security components that haven't been updated months after our upstream releases.
  • It works seamlessly with other common Community Edition platforms like Android, and exposes the most popular SQLCipher/SQLite features. This eliminates the guesswork of what features to enable or disable for every build.
  • It's the most compact, efficient, and fastest way to integrate SQLCipher into an Apple library. There is no need to avoiding repeated compilations of large amalgamated C files.
  • It is the only Swift package which will receive public support via SQLCipher forums and GitHub issues
  • Using SQLCipher.swift provides an easy way for developers to use their SQLCipher Commercial and Enterprise license with your library for enhanced SQLCipher features

Because of these benefits, use of the SQLCipher Swift Package is the recommended way for Apple-focused libraries to integrate a dependency on SQLCipher. This document will cover:

  1. Add the following to your Package.swift:
      dependencies: [
        .package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.10.0")
      ]
    
  2. Add SQLITE_HAS_CODEC cSettings to your target which has a dependency on SQLCipher.swift Package
    .target(
        name: "TargetName",
        dependencies: [.product(name: "SQLCipher", package: "SQLCipher.swift")],
        cSettings: [
            .define("SQLITE_HAS_CODEC", to: nil)
        ]
    )
    
  3. Import SQLCipher

    Import the SQLCipher module and remove any import SQLite3

    import SQLCipher
  4. Provide a mechanism to key the database:

    This will allow consumers to programatically set the key used to encrypt the database. Please see the SQLCipher API for Setting the key

  5. Provide a mechanism to get the cipher_version:

    This will allow consumers to programatically get the current SQLCipher version used and confirm that SQLCipher is properly loaded. Please see the SQLCipher API for cipher_version

  6. Optional: Provide a mechanism to apply a license code and get the cipher_fips_status:

    To support package consumers using SQLCipher Commercial products, add a mechanism to set a license code and get the cipher_fips_status.

  7. Optional: Provide convenience functions to call through to other SQLCipher API methods

    Please see a full list of the SQLCipher API.

The SQLCipher.swift Swift Package platforms:

  • iOS devices (arm64)
  • iOS simulators (arm64 -- Apple Silicon, x86_64)
  • Mac Catalyst (arm64 -- Apple Silicon, x86_64)
  • macOS (arm64 - Apple Silicon, x86_64)
  • tvOS (arm64)
  • tvOS simulators (arm64 -- Apple Silicon, x86_64)
  • watchOS (arm64, arm64_32, armv7k)
  • watchOS simulators (arm64 -- Apple Silicon, x86_64)
  • visionOS (arm64)
  • visionOS simulators (arm64 -- Apple Silicon, x86_64)

Please review the SQLCipher.swift Package details in the SQLCipher.swift GitHub Repository for additional information and license requirements.

As the official SQLCipher.swift Swift Package, we will be updating it with every new SQLCipher release.

SQLCipher release announcements with release notes are available on the SQLCipher discussion forum

SQLCipher major version include breaking changes which aren't backwards compatible with previous versions of SQLCipher. Use caution and test your packages when updating to the next major version. Consider implementing or exposing a mechanism to migrate between major versions using the cipher_migrate SQLCipher API convenienct function.

We throughly test the SQLCipher.swift Swift Package prior to every release. If you experience any bugs or issues with integration, please reach out to us at support@zetetic.net

In addition to the open source version of SQLCipher.swift Swift Package, we sell Commercial and Enterprise packages. This helps support our ongoing work on SQLCipher.

We've designed our commercial and enterprise packages to be drop-in replacements for Consumers who use Third Party Packages with dependencies on SQLCipher.swift community Swift Package