Integrating Firebase into Ionic + CocoPods Google Toolbox workaround

October 7, 2018

Since the Mobile SDK for Google Analytics is officially deprecated, Google is now recommending Firebase Analytics. When creating your Mobile Application using Ionic, Firebase is fairly easy to integrate using the native Firebase Plugin. However, there are a few workarounds needed to get the project to build correctly.


  1. Create Firebase Account and App Profile at:

  2. Download the config files and save to your project root folder. GoogleService-Info.plist for iOS. google-services.json for Android.

  3. Install plugin to project
    $ ionic cordova plugin add cordova-plugin-firebase
    $ npm install @ionic-native/firebase --save
  4. Add reference to config.xml file (if not element not present)
        <platform name="ios">
            <resource-file src="GoogleService-Info.plist" />

iOS Build Errors

You may encounter the error “ld: library not found for -lGoogleToolboxForMac” when building the project. This is caused by the CocoaPod dependencies and Ionic.

  1. Open a terminal to the platform/ios directory and run the following
    $ pod install
  2. When opening the project in XCode, use the .xcworkspace file instead of .xcodeproj

To streamline this process, create the following bash files to run before and after a platform is added (source: Ionic KB Article)

  1. Create the scripts

        pod repo update

        pod install --project-directory='./platforms/ios/'
  2. Reference the scripts in config.xml

    <platform name="ios">
        <hook src="" type="before_platform_add" />
        <hook src="" type="after_platform_add" />
  3. Add execute permissions to your scripts

    $ chmod +x
    $ chmod +x

Photo by Krivec Ales from Pexels