BbitbbitBook Dev Log #11 — App Crashes on Launch: What Crashlytics Found

"The App Closes When I Open It"
A review appeared shortly after 1.2.0 shipped.
"The app closes immediately when I open it and I can't get in."
Every developer dreads this. An app that won't even launch is a critical failure.
My first thought was that it might be device or iOS version specific. But it could be affecting many users silently, so I needed to respond quickly.
Firebase Crashlytics
Fortunately, the app had Firebase Crashlytics integrated.
Crashlytics automatically records crash events and sends them to the Firebase console — including which line of code triggered the crash, what device it occurred on, and what iOS version was running.
Without Crashlytics, I would have been looking at one review with no information about what went wrong.
Two Bugs Found
The Crashlytics logs showed multiple crash entries. Two distinct causes.
Bug 1: Barcode scanner
Camera-related code had a conflict from the update. A crash occurred when navigating to the barcode scan screen. The AVFoundation session initialization had broken during the update — code that worked perfectly in the previous version was now crashing.
Bug 2: Local user crash (the critical one)
Users in local mode (no account) who added a book with the "Currently Reading" status experienced a crash.
The cause: the code that shared logic between Realm and Firestore data models was using force unwrapping.
Force Unwrapping Was the Problem
In Swift, an Optional type may or may not contain a value.
Force unwrapping with ! assumes a value is always present and extracts it directly. If the value is nil, the app crashes at runtime.
Firestore's data model had certain fields that Realm's model didn't include. When shared logic processed a local user's data, it tried to force-unwrap a field that existed in the Firestore model but was absent in the Realm model. nil → crash.
The Fixes
Barcode scanner: Reviewed and restructured the AVFoundation session initialization.
Local user crash: Replaced force unwrapping with safe optional binding (if let, guard let). Values that might be absent are now handled gracefully rather than crashing.
Took the opportunity to audit the shared logic more carefully — identifying other places where Firestore and Realm model differences could create similar issues.
June 29, 2026 — Version 1.2.2
Version 1.2.1 had shipped with statistics screen improvements. On June 29, 2026, 1:59 AM, version 1.2.2 shipped with all crash fixes.
Three Things This Confirmed
First: Force unwrapping should be minimized, especially in code that handles multiple data model variants.
Second: Crash monitoring tools are non-negotiable for shipped apps. User reviews tell you something is wrong; Crashlytics tells you what and where.
Third: Large updates require explicit testing of local user scenarios. Logged-in and local users follow different code paths. Testing only one means the other's bugs ship.