D. The log message is sent to Crashlytics before the app crashes
Solution
Step 1: Understand Crashlytics log behavior
Calling log records a message that is sent to Crashlytics on next app launch after a crash.
Step 2: Analyze crash trigger
fatalError causes an immediate crash, but the log message is preserved for reporting.
Final Answer:
The log message is sent to Crashlytics before the app crashes -> Option D
Quick Check:
Crashlytics logs persist through crash [OK]
Hint: Crashlytics logs survive crashes for later reporting [OK]
Common Mistakes:
Assuming logs are lost on crash
Thinking log prevents crash
Confusing log with error throwing
4. You added Crashlytics to your app but crash reports are not showing up in the Firebase console. Which of these is the most likely cause?
medium
A. You used fatalError instead of assert
B. You forgot to call Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
C. You did not import UIKit in your Swift file
D. You called Analytics.logEvent instead of Crashlytics methods
Solution
Step 1: Check Crashlytics setup requirements
Crashlytics requires enabling data collection explicitly or via Info.plist to send crash reports.
Step 2: Identify missing configuration
Not calling setCrashlyticsCollectionEnabled(true) disables crash report sending.
Final Answer:
You forgot to call Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true) -> Option B
Quick Check:
Enable collection to send crash reports [OK]
Hint: Enable Crashlytics collection to receive reports [OK]
Common Mistakes:
Confusing Analytics logging with Crashlytics setup
Missing import statements
Thinking crash method choice affects reporting
5. You want to log a user property "user_level" with value "gold" in Firebase Analytics and also log a non-fatal error in Crashlytics when a payment fails. Which Swift code snippet correctly does both?
hard
A. Analytics.setUserProperty("user_level", forName: "gold")
Crashlytics.crashlytics().record(error: Error("Payment failed"))
B. Analytics.logEvent("user_level", parameters: ["gold"])
Crashlytics.crashlytics().log("Payment failed")