Get started with Firebase Crashlytics
Track your app crashes
As the latest news, all your apps on Fabric should be moved to Firebase before May 4, 2020. Here’re some steps to guide you migrate your crash tracking from Fabric to Firebase Crashlytics
Step 1: Create your project and application on Firebase
This step is not the main part of the article so if you already have a project on Firebase, move to Step 2
Open this link to go to your firebase console
Hit the plus button to create a new project
1.1 Name your project
1.2 Analytics Request
You can allow Google to analyze your data by turning on / off the toggle button in the image below
1.3 Select a default account to get analytics data from
Hit the Create Project button to finalize your project settings
Next, create your iOS application
Select the iOS icon to create your app and follow Firebase instructions
Step 2: Add Firebase Crashlytics
When you added GoogleService-Info.plist into your project and build it successfully. Here is the next step for you.
Add Firebase Crashlytics to your app by adding this line into your Podfile
pod 'Firebase/Crashlytics'
Then, run pod install
and open your .xcodeworkspace
Make sure you already imported Firebase
to your AppDelegate
by:
import Firebase
And config your Firebase with the following function in application:didFinishLaunchingWithOptions
FirebaseApp.configure()
Ok, try to rebuild your project again to make sure there are no problems
Step 3: Add Script to initialize Crashlytics
Select your target and select Build Phases on the bar and select New Run Script Phase
Open Run Script section and input the script below
"${PODS_ROOT}/FirebaseCrashlytics/run"
Rebuild your project again
Step 4: Upload dSYM files automatically
Try to make a fake crash by adding fatalError() to anywhere in your code
For example, I have a function is log in with Apple and I will add this function to simulate a crash
After implement and run a build, your app will be crashed when hit the apple sign-in button. Your crash will be shown on Firebase Crashlytics dashboard within 5 minutes
You’ll get a message like this
That’s mean you get the crash report, but need dSYM files to show them clearly. You need to add one more run script to upload dSYM files automatically
As Firebase mentioned, your script should be:
/path/to/pods/directory/FirebaseCrashlytics/upload-symbols -gsp /path/to/GoogleService-Info.plist -p ios /path/to/dSYMs
Let’s map the Firebase instruction to the correct run script
For example, my GoogleService-Info.plist in the PROD folder as the image below
We’ll have
/path/to/pods/directory = ${PODS_ROOT}/path/to/dSYMs = "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"/path/to/GoogleService-Info.plist = "${PROJECT_DIR}/BOLO/Config/PROD/GoogleService-Info.plist"
So, let’s combine together, the whole script should be
“${PODS_ROOT}/FirebaseCrashlytics/upload-symbols” -gsp “${PROJECT_DIR}/BOLO/Config/PROD/GoogleService-Info.plist” -p ios “${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}”
Now, you can build and simulate a crash again, it’s recorded
Thanks for reading!