Firebase Crashlytics and Fabric on iOS

Prenez
4 min readApr 13, 2018

--

Installing Fabric and Firebase Crashlytics
April 13 2018

CLEANED UP VERSION COMING SOON. Just wanted to make sure this gets into circulation immediately.

In short

1 create your ios app in Xcode, set it up with pods and code

2 create your app project in firebase, get the plist, get it in your app

3 create your app project in fabric, get fabric api key into your app

4 go back to firebase and link the two

DO IT IN THAT ORDER.

NOTE: YOU PROBABLY DON’T NEED EITHER RUN SCRIPT AT ALL. TEST THIS OUT.

HERE’S A VIDEO SHOWING HOW TO DO IT

https://youtu.be/5_LMZFgnbjg

In detail:

That date is the most important thing in this article, because we’re in between Firebase Crash Reporting (now defunct) and complete absorption of Fabric and Fabric Crashlytics into Firebase Crashlytics.

1. As above, Firebase Crash Reporting is defunct
2. Firebase Crashlytics is now the offered solution

I just wasted a day and a half because to get Firebase, Xcode and Fabric to dance together, you have to do things in the right order.

I’m assuming that you’ve already created an iOS project and that you’re not stupid. You just need to know how to get crash reporting into it.

I SET UP YOUR iOS PROJECT IN XCODE

First, install the cocoa pods as per this article
[https://firebase.google.com/docs/crashlytics/upgrade-from-crash-reporting]

1 pod ‘Firebase/Core’
2 pod ‘Fabric’, ‘~> 1.7.2’
3 pod ‘Crashlytics’, ‘~> 3.9.3’
4 In your terminal, navigate to your project directory and install the pods: pod install
5 Add this run script to the end of the build phase “${PODS_ROOT}/Fabric/run”

Now you have a project Workspace and installed Pods.

Now add this to your appdelegate.h
@import Firebase;

Now add this at the end of didFinishLaunching in the app delegate:
[Fabric with:@[[Crashlytics class]]];

In ViewDidLoad on your first ViewController that appears, add a line to crash the app. This is for testing.
[[Crashlytics sharedInstance] crash];

YOU’RE NOT DONE YET. YOU HAVE TO GET THE PLIST.

1. Create your account in Firebase.
2. Add your project (for your iOS app).
3. Include the bundle id for your app.
4. Get the googleservices-info.plist for your app
5. Drag the plist from downloads into the root of your Xcode app, just below the workspace.

NOW BUILD AND COMPILE

Ok. Now go back and DELETE this run script from the build phase:
{PODS_ROOT}/Fabric/run”

II FABRIC

I’m not going to give you details on installing Fabric here, but here are the troubles I ran into:

1. Get admin access to your Fabric account so you can see what’s going on
2. When the Fabric app lets you choose your source, pick the Workspace, not the project
3. BE SURE that PODS ROOT/Fabric/run command has been deleted

As you go through the install, Fabric adds
1 the Fabric API key to your Xcode project’s info.plist (<projectname>.plist). It’s in a Dictionary called Fabric.

Then Fabric asks you to cut and paste code it shows you as a run script to your build phase. Go ahead and do that.

WARNING IF YOU DID NOT DELETE {PODS_ROOT}/Fabric/run” THEN YOUR APP WILL NOT BUILD OR RUN

Then Fabric asks you to build and compile, go ahead and do that. When it’s through you’ll see a DONE message.

At this point, Fabric will have created your project IN FABRIC. IT IS ASSOCIATED WITH

1 THE FABRIC API KEY
2 YOUR APP’S BUNDLE ID

If you go into Fabric you can see your app.

III FIREBASE INSTALL

Back in Firebase now.

Find your app, click down into it’s detail. You’ll see an arrow

= — →>>>> GO TO CRASHLYTICS

THEN you’ll be shown a page that invites you to set up Crashlytics. On the list of options, say ‘yes, I’ve installed the SDK’

THEN you’ll be shown a button saying LINK TO THE APP

AFTER you press that you’ll be shown the Fabric screen and PROBABLY be asked to log in to Fabric. Be sure you log into the right account.

REMEMBER SUCCESSFUL LINKING DEPENDS ON THE FABRIC API KEY IN THE APP AND THE BUNDLE ID IN THE APP, IN THE APP IN FIREBASE, AND IN FABRIC ALL AT THE SAME TIME

ALSO REMEMBER YOU MUST HAVE THE RIGHT PLIST INSTALLED. THAT HAS THE FIREBASE INFORMATION.

NOW you’re asked to link the firebase app with the fabric app, ‘app’ meaning your app project set up in two different systems, say yes.

Now your apps are linked. If you run the project and let the test crashes happen, you should see them in both the Firebase system and the Fabric system. AT THIS TIME there is more, better data in the Fabric system.

NOTE DEBUG SETTINGS

you have to generate DEBUG symbols

you have to set DWARF setting correctly.

MORE TO COME on these.

show the settings:

show where the dsym file is

crashes in fabric

crashes in firebase

--

--

Prenez

Writes iOS apps in Swift and stories in American English.