Swiftpack.co - readium/r2-lcp-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by readium.
readium/r2-lcp-swift 2.2.0
Swift LCP module
⭐️ 5
🕓 40 weeks ago
.package(url: "https://github.com/readium/r2-lcp-swift.git", from: "2.2.0")

:warning: ᴛʜɪs ʀᴇᴘᴏsɪᴛᴏʀʏ ɪs ᴅᴇᴘʀᴇᴄᴀᴛᴇᴅ :warning:

We moved all the r2-*-swift modules to a single repository: swift-toolkit.


Swift wrapper module for LCP support

Changes and releases are documented in the Changelog

Adding the module to your iOS project

Note: requires Swift 4.2 (and Xcode 10.1).


Carthage is a simple, decentralized dependency manager for Cocoa. To install ReadiumLCP with Carthage:

  1. Make sure Carthage is installed and up-to-date.

  2. Update your app's Cartfile to include the following:

    github "readium/r2-lcp-swift" "develop"
  3. Run:

  4. Add the appropriate framework. ```

Integration in your project

After adding the r2-lcp-swift module to your project and the private R2LCPClient.framework provided by EDRLab, you can use LCP in your app by creating an instance of LCPService.

LCPService expects an implementation of LCPClient, which acts as a facade to R2LCPClient.framework. Copy and paste the following:

import R2LCPClient
import ReadiumLCP

let lcpService = LCPService(client: LCPClient())

/// Facade to the private R2LCPClient.framework.
class LCPClient: ReadiumLCP.LCPClient {

    func createContext(jsonLicense: String, hashedPassphrase: String, pemCrl: String) throws -> LCPClientContext {
        return try R2LCPClient.createContext(jsonLicense: jsonLicense, hashedPassphrase: hashedPassphrase, pemCrl: pemCrl)

    func decrypt(data: Data, using context: LCPClientContext) -> Data? {
        return R2LCPClient.decrypt(data: data, using: context as! DRMContext)

    func findOneValidPassphrase(jsonLicense: String, hashedPassphrases: [String]) -> String? {
        return R2LCPClient.findOneValidPassphrase(jsonLicense: jsonLicense, hashedPassphrases: hashedPassphrases)


Dependencies in this module

  • R2Shared : Custom types shared by several readium-2 Swift modules.
  • ZIPFoundation : Effortless ZIP Handling in Swift
  • SQLite.swift : A type-safe, Swift-language layer over SQLite3.
  • CryptoSwift : CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift


Stars: 5
Last commit: 38 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

40 weeks ago

Take a look at the migration guide

Nothing new for r2-lcp-swift in Readium Swift 2.2.0.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics