DEV Community

Cover image for 5 Painful Bugs I Hit Building an iOS EPUB Reader with SwiftUI + WKWebView
KevinLeeeee323
KevinLeeeee323

Posted on • Originally published at reddit.com

5 Painful Bugs I Hit Building an iOS EPUB Reader with SwiftUI + WKWebView

I got tired of reaching out of my blanket to tap the screen every page, so I built SwiftBook: an Apple Books-style EPUB reader for iOS that lets you turn pages with the volume buttons.

UI Display

Use Volum Button As Page Turner

What it does:

  • Import EPUBs → read with tap / swipe / progress bar / volume button page turns
  • 5 fonts (PingFang, Source Han Serif Regular/SemiBold/Bold, Georgia)
  • 4 reading themes (white · warm · dark · eye-care green)
  • Font size, line spacing, margins, alignment — all adjustable
  • Resume reading, TOC with chapter jump

Tech stack: SwiftUI + WKWebView. Pagination uses CSS multi-column layout rather than native scroll. Volume button detection uses AVAudioSession KVO + a silent looping WAV to keep the audio session alive.

The README has a detailed "Lessons Learned" section covering:

  • Why WKWebView dimensions must be constant (or pages jump around)
  • The quote-escaping bug that silently broke ALL JS interactivity
  • Why you can't read @Binding during loadContent (progress reset to 0%)
  • Gesture arena conflicts between tap zones and swipe on WebView

🔗 GitHub: https://github.com/KevinLeeeee323/SwiftBookApp

MIT licensed. Free to use, modify, contribute. Built with help from Claude / Codex / Deepseek.

Would love feedback — this is my first iOS app!

Top comments (0)