Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Getting Firebase Analytics in Cordova for iOS

$
0
0

I’ve had a terrible time getting Firebase Analytics working in iOS, but I finally managed to get it to work on my Ionic v6 Angular App. I’m sure there are other people having these same issues so I’m going to explain the various issues I encountered and how I addressed them.

There are multiple modules that implement Firebase Analytics from the Ionic Community plugins. The main ones are Analytics-Firebase and Firebase-Analytics.

These two modules correspond to cordova-plugin-analytics and cordova-plugin-firebase-analytics. I tried both and could not get past running Capacitor sync with either one in a fresh Ionic Angular project that only had the standard Capacitor starter packages plus one of these two Firebase Analytics packages.

NOTE: When there is a dash in the name of Firebase-Analytics and Analytics-Firebase I’m referring to the module of that name and not to the name of the “Firebase Analytics” service itself. Yeah, this is horrible naming.

When pod install is run, you will see this error:

The ‘Pods-App’ target has transitive dependencies that include statically linked binaries: (/ios/App/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework)

To get around this, you need to edit the Podfile in the ios/App folder that is generated when you added ios as a Capacitor platform.

In that Podfile, change use_frameworks! to this:

use_frameworks! :linkage => :static

If you see the following error when you build your project in XCode there may be one more step.

Command CompileSwiftSources failed with a nonzero exit code

If you see this, also add this to your Podfile where it says # Add your Pods here

pod ‘Firebase/Analytics’

After this run:

ionic build
ionic cap sync

Then build your project in XCode. The build should complete if you’re using Firebase-Analytics. If you’re using Analytics-Firebase, there will be additional errors to resolve. You may find the following solutions helpful in this case.

https://github.com/appfeel/analytics-google/issues/21#issuecomment-530480604
https://github.com/apache/cordova-plugin-file-transfer/issues/258
https://stackoverflow.com/questions/63168114/firebase-analytics-setscreenname-deprecated

If the build completes, but Firebase Analytics still isn’t working or your app crashes immediately after loading, check your error messages. If you see something about it not being able to find GoogleService-Info.plist, see this solution:
https://stackoverflow.com/questions/45317777/could-not-find-a-valid-googleservice-info-plist-in-your-project

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles