trackslash
VAULT-104 P2 For an agent

Mac app: make PDF backups and images without UIKit

0
Sub-issue of VAULT-101 P2 A native Mac app

Description

Part of VAULT-101. It needs VAULT-103.

The PDF backup (VaultExport, 9 UIKit files) and ImageTools (all UIKit) render with UIKit, so the Mac can't make or print a backup yet.

  • Split the rendering behind a platform-neutral interface: one UIKit implementation for iOS and one AppKit or Core Graphics implementation for macOS. Prefer Core Graphics, CoreText and PDFKit wherever one implementation can serve both platforms.
  • The PDF stays the same format: the same QR payloads, page layout, plain-text header and password hint (G58), so a backup made on either platform restores on the other.
  • Tests:
    • the existing VaultExport and ImageTools tests pass unchanged on iOS;
    • the QR payloads match byte for byte on macOS, with snapshot tests for the macOS rendering;
    • a backup made on the Mac restores on iOS in a test, and one made on iOS restores on the Mac.

Done when

VaultExport and ImageTools build on macOS, a Mac-made PDF backup restores on iOS and the other way round, and no iOS test changed.

Linked issues

0

GitHub

0

No branches or pull requests linked.

Comments

1
Bradley

Done in https://github.com/badbundle/vault-app/pull/714 (merged as 3b497c13). The Mac makes the same PDF backup and QR codes as the iPhone.

  • One layout, two renderers. CoreGraphicsPDFRenderer does on the Mac what UIGraphicsPDFRenderer does on iOS, so VaultExport's drawing code serves both. iOS keeps UIKit (PlatformPDFRenderer is UIGraphicsPDFRenderer there), so its PDFs and snapshots are byte for byte as they were.
  • QR codes are identical: the Mac draws them at 3×, nearest neighbour, as the iPhone does, so each is the same 214-pixel image, and the Mac's QR snapshots match the iPhone's pixel for pixel.
  • Restores both ways: pdf-made-on-mac.pdf joins the backup corpus and every iOS run restores it; the iOS-made PDFs restore on the Mac in every Mac run. Every corpus PDF also restores from its QR codes alone, read from the PDF's images as scanning paper would.
  • "No iOS test changed": none checks anything different. A few now spell a UIKit type with its alias (the same type on iOS), and one goes through TestHelpers' assertSnapshot. The iOS snapshot files are untouched.
  • One visible difference: the Mac's text has slightly taller lines, so its QR codes start a few points lower on the page. Nothing a restore reads differs.