Firebase Crashlytics Integration In iOS Swift

Prerequisite:-

1. Xcode 10.2

2. Swift 5

3. Firebase Console Account

Step 1:- Create a new XCODE project with a button

Step 2:- Generate pod file for your project and install pods as given below and reopen your project using *.xcworkspace file:-

Step 3:- After successful installation of pods go to your Firebase Console. If you do not have any existing Firebase application then your screen should look like this:-

Step 4:- Now tap on ‘Create a Project’ button and create a new project, enter the name of a new Firebase project and accept terms & conditions and then tap on create the project. It will take some time to create a project. After the creation of the project click on continue.

Step 5:- Now choose your platform of application, in our case, we will choose iOS.

Step 6:- it will open a new form to register your Xcode project with firebase where you will have to enter your app details like iOS bundle Identifier (Then at the left select the top project item in the project navigator. Then select TARGETS -> GeneralBundle Identifier is found under Identity ) etc. and Finally tap on register app.

Step 7:- Download GoogleService-Info.plist file and place it in your project

step 8:- Now there is an important step i.e.,  Select the top project item in the project navigator at the left. Then select TARGETS -> Build Settings and search for Build Options.

Now under build options select “DWARF with dSYM File” as debug information format.

Step 9:- Now again go on the browser and click on next after downloading google info plist file. Now it will say to install a pod which we have installed already so, skip this step and click on next.

Now it will ask to add Firebase initialization code into our app delegate file as given below:-

After addition of above code click on next and run your app so that Firebase can recognize your app. After successful recognition of your app, tap on ‘Continue to console’ or you can skip this process by clicking on skip this step:-

Step 10:- Select Crashlytics from the left panel that would look like this as given below and tap on ‘Set up Crashlytics’:-

Now, select ‘No’ if you are creating a fresh and new application or ‘Yes’ if you are migrating a fabric app to Firebase. In our case, I am going to select No.

Now click on Go to Crashlytics docs

Step 11:- Follow given steps on Crashlytics docs. you can skip 1st and 2nd step as we have already completed it. Directly follow step 3

In Run Script add – “${PODS_ROOT}/FirebaseCrashlytics/run”

in Input Files add – ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH} OR ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}

if you are not having Run Script section you can add it by clicking on icon.

Step 12:- Whoa..  we are almost done now just create action outlet of your UI button which we have designed and put a code to crash your application.

Step 13:- Now follow these given below instructions to log your first crash:-

1. Build and Run your application (on simulator or iOS device)

After the successful running of your app, Firebase Console will look like this. Just press ‘Go to the Crashlytics dashboard’ button:-

2. Stop the running app from Xcode by pressing the stop button

3. Now run your application from device’s or simulator’s home screen

4. Tap on the crash button to crash your application.

5. Now rerun your application from home screen and look at crashlytics dashboard

6. If the crash is not logged in then try to crash your application 4-5 time else you have not followed complete instructions of this blog. Kindly go through all instructions.

Dashboard will look somewhat like this with crash informations

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s