Skip to main content
Complete setup guide: See /docs/integrations/Crashlytics.md in the project

What is Crashlytics?

Crash Reports

Automatic crash detection with stack traces

Error Tracking

Non-fatal errors and custom logging

User Privacy

GDPR compliant with user consent toggle

Free Tier

Unlimited reports on Firebase free tier

Quick Setup

1

Create Firebase Project

  1. Go to Firebase Console
  2. Click “Add project”
  3. Enter project name
  4. Create project
2

Add iOS App

  1. Firebase Console → Add app → iOS
  2. Enter your bundle ID (from Config/App.xcconfig)
  3. Download GoogleService-Info.plist
3

Add to Xcode

  1. Drag GoogleService-Info.plist into Xcode
  2. ✅ Check “Copy items if needed”
  3. ✅ Select “SwiftAIBoilerplatePro” target
  4. Click “Add”
4

Enable Feature Flag

Edit SwiftAIBoilerplatePro/Composition/FeatureFlags.swift:
public static var crashlyticsEnabled: Bool {
    #if DEBUG
    return false  // or true to test
    #else
    return true
    #endif
}
5

Build and Run

The boilerplate automatically:
  • Detects GoogleService-Info.plist
  • Initializes Crashlytics
  • Sets up user tracking
  • Respects user privacy settings

How It Works

Automatic Integration

The boilerplate includes a CrashReporter protocol that automatically switches between Firebase Crashlytics and NoOp based on availability:
// From CompositionRoot.swift (automatic)
if FeatureFlags.crashlyticsEnabled && GoogleService-Info.plist exists {
    crashReporter = CrashlyticsCrashReporter()  // Real tracking
} else {
    crashReporter = NoOpCrashReporter()         // No tracking
}
No code changes needed! Just add the plist file.

User Privacy

Users control crash reporting in Settings → Share Diagnostics:
  • ✅ ON → Crashes sent to Firebase
  • ❌ OFF → No data sent
GDPR Compliant:
  • Never sends email addresses
  • User has opt-out control
  • Clear privacy disclosure

What Gets Tracked

Automatically

  • Crash reports with stack traces
  • Device info (model, iOS version)
  • App version
  • User ID (anonymized, no email)
  • Session info

Custom (Optional)

  • Non-fatal errors
  • Custom logs/breadcrumbs
  • User attributes (subscription tier, theme, etc.)

Testing

Test Crash Reporting

// Add a test crash button (DEBUG only)
#if DEBUG
Button("Test Crash") {
    fatalError("Test crash for Firebase")
}
#endif
Steps:
  1. Tap “Test Crash” button
  2. App crashes
  3. Restart app
  4. Wait 5 minutes
  5. Check Firebase Console → Crashlytics

Test Non-Fatal Errors

// Log non-fatal error
crashReporter.recordError(
    AppError.network(code: 500, message: "Test error"),
    context: ["screen": "chat"],
    isFatal: false
)

Viewing Reports

Firebase Console:
  1. Go to Firebase Console
  2. Select your project
  3. Crashlytics (in sidebar)
  4. View crashes, errors, logs
Reports include:
  • Stack traces
  • Device information
  • User ID
  • App version
  • Custom logs

Cost

Firebase Free Tier:
  • ✅ Unlimited crash reports
  • ✅ 30-day retention
  • ✅ Basic analytics
  • ✅ Enough for most apps
Blaze Plan (optional):
  • Extended retention
  • More features
  • Pay as you go (very low cost)

Full Integration Guide

See complete details in /docs/integrations/Crashlytics.md

Feature Flags

Configure in Composition/FeatureFlags.swift

Settings Module

User consent toggle

Privacy Policy

Update Resources/privacy.md to mention crash reporting

Need Help?

The boilerplate handles all the integration automatically. You just need to:
  1. Add GoogleService-Info.plist
  2. Enable feature flag
  3. Build and run
If you have issues, check the troubleshooting section in /docs/integrations/Crashlytics.md.
I