⚠️ ᴛʜɪs ʀᴇᴘᴏsɪᴛᴏʀʏ ɪs ᴅᴇᴘʀᴇᴄᴀᴛᴇᴅ⚠️ 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
Note: requires Swift 4.2 (and Xcode 10.1).
Carthage is a simple, decentralized dependency manager for Cocoa. To install ReadiumLCP
with Carthage:
-
Make sure Carthage is installed and up-to-date.
-
Update your app's
Cartfile
to include the following:github "readium/r2-lcp-swift" "develop"
-
Run:
mkdir -p Carthage/Build/iOS
carthage update --use-xcframeworks
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)
}
}
- 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