CalibreSync Development Notes
CalibreSync is an iOS extension which allows you to browse your Calibre library from the Files application on your iPhone and iPad.
Development Environment Setup¶
Install Cocoapods¶
Follow Cocoapod installation instructions here: Ruby Cheatsheet
Build Project¶
# Checkout codebase
git clone git@github.com:peddamat/CalibreSync3.git CalibreSync
# Install deps
pod install
# Open workspace
open CalibreSync3.xcworkspace
Hit CMD+B
to build the project.
Components¶
The extension consists of three parts:
- CalibreSync
- The main application allows users to configure CalibreSync by selecting one of the following:
- URL for Calibre feed
- Location of Calibre database
- The main application allows users to configure CalibreSync by selecting one of the following:
- CalibreSyncExtension
- The extension does the following:
- Adds 'CalibreSync' to the Locations menu in the Files app
- The extension does the following:
- CalibreSyncExtensionUI
- Displays the downloaded Calibre library in the Files app
Features¶
- Download and load Calibre database
- Mount SMB fileshare
- Locate metadata.db
- Parse metadata.db using SQLite
- Cache metadata.db for offline usage
- Display book covers from Calibre database
- Download and cache covers for offline usage
- Download books from Calibre database
- Edit book metadata
- Resync metadata with SMB database
- Create Book model
- Create BookList view
- Create BookDetail view
- Create button to load Fileshare
Architecture¶
How books are loaded from Calibre Library¶
- The user selects the directory containing the Calibre Database
- Check for existence of metadata.db in the root of this directory
- Load Calibre database from metadata.db
- The 'Books' table contains the following relevant fields:
- id
- title
- pubdate
- author_sort
- path
- has_cover
- The 'Data' table contains the available formats for each book in the 'Books' table, and contains the following relevant fields:
- name
- The detailed metadata associated with each book is contained in the metadata.opf XML file stored in each Book's 'path'
Next Steps¶
- Copy example Calibre database to project and load book entries
- Create Record stubs for Calibre book entries
- Load Calibre database and print out all book titles
- Display book covers in waterfall grid
- Load Calibre database from file share
- Load .epub from fileshare
- Refactor CalibreSync v1 code to allow loading of Calibre Database from fileshare
- Implement infinite scrolling to load subsequent books in grid view
- Implement book cover caching
- Implement GRDB Scope Adapters to allow retrieving both the full database and initial set of books for main screen
- Implement download folder scanning
- Implement PDFExpert-like SMB connection workflow
References¶
- Using UIKit DocumentPicker for selecting Calibre Database:
- https://gist.github.com/richo/61f308f5e4ba1fe7eefb8035aaa7817a
- https://github.com/developer-shubham101/iOS-Examples
- file:////Users/me/Documents/Source/iOS/ThirdParty/iOS-Examples
- Display modal for DocumentPicker
- Interfacing with UIViewControllers from SwiftUI:
- Supporting filtering for .db files:
- Allowing books to be accessible via Files app:
- Sharing data between applications and extensions:
- Displaying books in grid:
- https://github.com/paololeonardi/WaterfallGrid
- file:///Users/me/Documents/Source/iOS/ThirdParty/WaterfallGrid
- https://github.com/SwiftUIExtensions/Grid
- file:///Users/me/Documents/Source/iOS/ThirdParty/Grid
- https://github.com/paololeonardi/WaterfallGrid
- Saving setting via UserDefaults:
- Pull to refresh:
- Share sheet:
- Loading images from file:/// URLs
- Infinite scrolling
- Onboarding screen / workflow
- Slide-out Menu
- Search bar
- Fuzzy Search
Testing¶
Architecture¶
Database¶
- https://medium.com/@gwendal.roue/how-to-build-an-ios-application-with-sqlite-and-grdb-swift-d023a06c29b3
- https://github.com/groue/GRDB.swift/tree/master/Documentation/DemoApps/GRDBDemoiOS/GRDBDemoiOS
Uncategorized¶
- https://github.com/Juanpe/About-SwiftUI
- https://medium.com/flawless-app-stories/a-swifty-way-to-pick-documents-59cad1988a8a
Todo¶
Last update: 2023-03-28