Javatpoint Logo
Javatpoint Logo

Firebase Crashalytics iOS Swift

Firebase Crashalytics is a real-time, light-weight crash reporting tool for iOS and Android applications provided by Google. It keeps track of the crash issues that occur in the applications in real-time. In this tutorial, we will discuss how to setup crashalytics in the iOS applications and the firebase console.

Follow the following steps to configure firebase crashalytics for the iOS application.

1. Go to https://firebase.google.com in your web browser.

2. Click on get started and login to your google account to access the services of the firebase.

3. Now, it will show up the list of projects that are associated with firebase on this google account.

Firebase Crashalytics iOS Swift

4. We need to add the new project by clicking on the + icon. This will prompt us to provide the project name. Give the one and press continue as given in the following image.

Firebase Crashalytics iOS Swift

5. In step 2 of 3, it will prompt us to configure google analytics for our project CrashalyticsDemo. We can enable or disable google analytics for the firebase project as given in the following image.

Firebase Crashalytics iOS Swift

Enable Google Analytics for the project and click Continue. In the next step, it will prompt us to select the google account username as given in the following image.

Firebase Crashalytics iOS Swift

Select an account to configure Google Analytics and click Create project. This will create the new project as given in the following image.

Firebase Crashalytics iOS Swift

6. Meanwhile, we need to create the iOS project with the same name in XCode that will be added to this newly added firebase project.

Firebase Crashalytics iOS Swift

On the Firebase console in the browser, add an iOS application by clicking on the iOS icon provided on the project overview screen.

Firebase Crashalytics iOS Swift

It will prompt us to provide the application's bundle id. We need to give the same bundle id that we have given in the XCode project. The rest fields of the form are optional, as shown in the following image.

Firebase Crashalytics iOS Swift

7. We need to add the config file (GoogleService-Info.plist) file to our XCode project. Download the GoogleService-Info.plist file from the firebase console, as shown in the following image.

Firebase Crashalytics iOS Swift

However, we can download the config file later also.

8. We need to add the Firebase SDK for crashalytis and analytics in the iOS application through cocoapods. For that purpose, configure cocoapods on the system (if not already done). To configure cocoapods, run the following command on the terminal.

After installing cocoapods, move to the project directory in the terminal and run the following command to initialize the podfile in the project.

This will create a podfile in the project directory. Open the podfile and add the pods for Firebase crashalytics. The code for the podfile is given below.

Now, run the following command to install the pods defined in the above-mentioned podfile.

This will install all the necessary pods for the firebase crashalytics setup.

Firebase Crashalytics iOS Swift

9. When the pod installation is complete, close the current XCode project and open the xcworkspace file for your project. In Project's AppDelegate file, we need to write the code to configure firebase in our project.

Now, we are done with the firebase integration in our iOS application. However, we need to add the required settings in XCode to get started with firebase crashaytics.

10. Open Build Phases in XCode, and add a new Run Script Phase for crashalytics. Adding a Run Script Phase in XCode is shown in the following image.

Firebase Crashalytics iOS Swift

Add the following Script as the new Run Script to run the crashalyics.

We also need to provide the app's dSYM location as an input file. It will enable crashalytics to automatically generate the dSYMs for the applications. For this purpose, create another run script and add the following script to it.

11. We must also enable crashalyics in the firebase console. For that purpose, go to crashalytics in services on the firebase console and click Enable Crashalyics, as shown in the following image.

Firebase Crashalytics iOS Swift

12. We need to build, run, and crash our application to see the crash report on the firebase console.

Firebase Crashalytics iOS Swift

For that purpose, build and run the iOS app in XCode. We don't need to run the app in debug mode. We can see the crash reports on the firebase console after running and crashing the application.


Next TopicIOS app lifecycle




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA