A powerful and modern Swift library for parsing EPUB documents
EPUBKit provides a comprehensive solution for parsing and extracting information from EPUB files in Swift. Built with modern Swift practices and designed for reliability, it supports both EPUB 2 and EPUB 3 specifications while maintaining a clean, intuitive API.
Add EPUBKit to your project via Xcode or by adding it to your Package.swift:
dependencies: [
.package(url: "https://github.com/witekbobrowski/EPUBKit.git", from: "1.0.0")
]
pod 'EPUBKit'
import EPUBKit
// Parse an EPUB file
guard let epubURL = Bundle.main.url(forResource: "book", withExtension: "epub"),
let document = EPUBDocument(url: epubURL) else {
print("Failed to load EPUB")
return
}
// Access document metadata
print("Title: \(document.title)")
print("Author: \(document.author)")
print("Publisher: \(document.publisher)")
print("Language: \(document.language)")
// Access document structure
print("Chapters: \(document.spine.items.count)")
print("Resources: \(document.manifest.items.count)")
// Access metadata details
if let creator = document.metadata.creator {
print("Author: \(creator.name)")
print("Role: \(creator.role)")
print("File as: \(creator.fileAs)")
}
// Iterate through spine items (reading order)
for spineItem in document.spine.items {
if let manifestItem = document.manifest.items[spineItem.idref] {
print("Chapter: \(manifestItem.path)")
print("Media Type: \(manifestItem.mediaType)")
}
}
// Access table of contents
func printTOC(_ toc: EPUBTableOfContents, level: Int = 0) {
let indent = String(repeating: " ", count: level)
print("\(indent)- \(toc.label)")
for child in toc.children {
printTOC(child, level: level + 1)
}
}
printTOC(document.tableOfContents)
EPUBKit supports the EPUB specification standards:
Contributions are welcome! Please feel free to submit a Pull Request.
EPUBKit is available under the MIT license. See the LICENSE file for more info.
22 followers Β· starred Jan 2021
167 followers Β· starred Dec 2025
A powerful and modern Swift library for parsing EPUB documents
EPUBKit provides a comprehensive solution for parsing and extracting information from EPUB files in Swift. Built with modern Swift practices and designed for reliability, it supports both EPUB 2 and EPUB 3 specifications while maintaining a clean, intuitive API.
Add EPUBKit to your project via Xcode or by adding it to your Package.swift:
dependencies: [
.package(url: "https://github.com/witekbobrowski/EPUBKit.git", from: "1.0.0")
]
pod 'EPUBKit'
import EPUBKit
// Parse an EPUB file
guard let epubURL = Bundle.main.url(forResource: "book", withExtension: "epub"),
let document = EPUBDocument(url: epubURL) else {
print("Failed to load EPUB")
return
}
// Access document metadata
print("Title: \(document.title)")
print("Author: \(document.author)")
print("Publisher: \(document.publisher)")
print("Language: \(document.language)")
// Access document structure
print("Chapters: \(document.spine.items.count)")
print("Resources: \(document.manifest.items.count)")
// Access metadata details
if let creator = document.metadata.creator {
print("Author: \(creator.name)")
print("Role: \(creator.role)")
print("File as: \(creator.fileAs)")
}
// Iterate through spine items (reading order)
for spineItem in document.spine.items {
if let manifestItem = document.manifest.items[spineItem.idref] {
print("Chapter: \(manifestItem.path)")
print("Media Type: \(manifestItem.mediaType)")
}
}
// Access table of contents
func printTOC(_ toc: EPUBTableOfContents, level: Int = 0) {
let indent = String(repeating: " ", count: level)
print("\(indent)- \(toc.label)")
for child in toc.children {
printTOC(child, level: level + 1)
}
}
printTOC(document.tableOfContents)
EPUBKit supports the EPUB specification standards:
Contributions are welcome! Please feel free to submit a Pull Request.
EPUBKit is available under the MIT license. See the LICENSE file for more info.
22 followers Β· starred Jan 2021
167 followers Β· starred Dec 2025