How do I integrate Firebase Analytics in Swift?

To integrate Firebase Analytics into your Swift application, follow these steps:

  1. Set up a Firebase project in the Firebase Console.
  2. Add your iOS application to the project and download the GoogleService-Info.plist file.
  3. Drag and drop the GoogleService-Info.plist file into your Xcode project.
  4. Install Firebase SDK using CocoaPods. Add the following line to your Podfile:
pod 'Firebase/Analytics'
  1. Run the command pod install in your terminal to install the dependencies.
  2. Import Firebase in your AppDelegate.swift file:
import Firebase
  1. Initialize Firebase in the application(_:didFinishLaunchingWithOptions:) method:
FirebaseApp.configure()

Now, you can log events in your app.

Analytics.logEvent("event_name", parameters: [ "param_name": "param_value"])

With these steps, Firebase Analytics will be integrated into your Swift application!


Firebase Analytics Swift integration iOS Analytics Firebase SDK CocoaPods