Latest 1.0.0
Homepage https://github.com/stonezhl/Bookbinder
License MIT
Platforms ios 12.2, requires ARC
Dependencies Kanna, ZIPFoundation
Authors

A Swift ePub parser framework for iOS.

Requirements

  • Swift 5.0+
  • iOS 12.2+
  • ARC

Usage

  1. Create bookbinder instance with default configuration
    // default configuration uses `NSTemporaryDirectory` as root directory to unzip ePub file
    let bookbinder = Bookbinder()
  2. Create bookbinder instance with custom configuration
    let configuration = BookbinderConfiguration(rootURL: customRootURL)
    let bookbinder = Bookbinder(configuration: configuration)
  3. Parse ePub file by one line
    let ebook = bookbinder.bindBook(at: ePubFileURL)
  4. Ready made interface of ebook
    // cover image
    let coverImageURLs = ebook.coverImageURLs
    // toc
    let tocURL = ebook.tocURL
    // ncx
    let ncx = ebook.ncx
    // primary spine items
    let pages = ebook.pages
    // others
    let mainAuthor = ebook.opf?.package?.metadata?.creators.first
  5. Playground in BookbinderTests
    // study `Bookbinder` from unit test
    let ebook = EPUBBook(identifier: "Alice's_Adventures_in_Wonderland", contentsOf: url)
    expect(ebook).notTo(beNil())
    expect(ebook?.identifier).to(equal("Alice's_Adventures_in_Wonderland"))
    expect(ebook?.baseURL).to(equal(url))
    expect(ebook?.resourceBaseURL).to(equal(url.appendingPathComponent("epub")))
    expect(ebook?.opf).notTo(beNil())
    expect(ebook?.uniqueID).to(equal("url:https://standardebooks.org/ebooks/lewis-carroll/alices-adventures-in-wonderland"))
    expect(ebook?.releaseID).to(equal("(ebook?.uniqueID ?? "")@2017-03-09T17:21:15Z"))
    expect(ebook?.publicationDate).to(equal(ISO8601DateFormatter().date(from: "2015-05-12T00:01:00Z")))
    ...

Installation

Cathage

Please add it to your Cartfile:

github "stonezhl/Bookbinder" ~> 1.0.0

CocoaPods

Please add it to your Podfile:

use_frameworks!
pod 'Bookbinder', '~> 1.0.0'

License

Bookbinder is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "Bookbinder",
    "version": "1.0.0",
    "summary": "A Swift ePub parser framework for iOS.",
    "homepage": "https://github.com/stonezhl/Bookbinder",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Stone Zhang": "[email protected]"
    },
    "social_media_url": "https://twitter.com/stonezhl1",
    "swift_version": "5.0",
    "platforms": {
        "ios": "12.2"
    },
    "source": {
        "git": "https://github.com/stonezhl/Bookbinder.git",
        "tag": "1.0.0"
    },
    "source_files": "Bookbinder/**/*.{h,swift}",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2"
    },
    "dependencies": {
        "Kanna": [
            "~> 5.0.0"
        ],
        "ZIPFoundation": [
            "~> 0.9"
        ]
    }
}

Pin It on Pinterest

Share This