Solving Firebase Analytics tracking issue in Naukri Recruiter iOS app 📈

Rushabh Singh
Naukri Engineering
Published in
4 min readOct 17, 2022
Photo by Isaac Smith on Unsplash

Legends used to say that no matter how great or impactful features you build for your customers, if you do not have Data or numbers to understand user’s behaviour, you will not be able to make informed decisions regarding app marketing and performance optimizations.

Background

A few months back, we did a revamp of Naukri Recruiter iOS app where we built the whole app from scratch with new frameworks, updated libraries & fresh designs.

Everything was going great until we realised that Firebase analytics is not showing data for this revamped version 😧

We all know how crucial Firebase is for our Apps as it provides insights on app usage and user engagement.

Firebase collects usage and behavioural data for your app and logs two primary types of information:

  • Events: What is happening in your app, such as user actions, system events, or errors.
  • User properties: Attributes you define to describe segments of your user base, such as language preference or geographic location.

These Analytics reports help us understand clearly how our users behave, which enables us to make informed decisions regarding app marketing and performance optimizations.

Problem

Firebase Analytics not reporting data for revamped version of the App.

Solutions

We started exploring all the possible solutions.

To verify whether the issue exists at our end & not Firebase, we checked Analytics for other iOS apps & Android apps which was working fine.

We examined the GoogleService-Info.plist file & compared it with older version of the App to verify whether both have same keys & Ids.

We went through the Firebase official documentation to recheck the SDK integration process step by step.

Photo by Tim Gouw on Unsplash

And after going through several Firebase SDK Github open issues https://github.com/firebase/firebase-ios-sdk , we found out that Analytics was not working for version 7.5.0 & above.

So one of the straightforward solutions was to downgrade the Firebase SDK version & release the app to all users.

Another solution was to understand the reasons behind it & fix it properly.

Real Solution

As Firebase mentions in its official documentation that Google Analytics requires adding the -ObjC linker flag to our target's build setting.

And when we checked the build setting, -Objc flag was missing🤔

So after going through this thread

we came to know that CocoaPods adds -ObjC itself on 7.4.0, but not on versions above.

Now this might be the CocoaPod issue since SPM documentation mentions this, but it was not required for CocoaPods.

They have fixed this in https://github.com/CocoaPods/CocoaPods/pull/10460

We have manually added the -Objc linker flag & now Firebase Analytics is working fine as expected 🎯

Learnings

What is -Objc flag & why do we need it?

The -ObjC flag is required when Objective C classes and categories need to be dynamically loaded from static libraries. This flag causes all classes in all linked static libraries to be included in the app, whether or not they are actually used.

--

--

Rushabh Singh
Naukri Engineering

Moving fast without breaking things 👨‍💻……. Exploring Mobile Apps development