Firebase
Analytics
Xcode
iOS Development
Mobile App Tracking

Turning Firebase Analytics on on Xcode

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Turning on Firebase Analytics in an Xcode project means more than just adding a package. You need a Firebase project, an iOS app registration with the correct bundle identifier, the GoogleService-Info.plist file, the Analytics SDK in Xcode, and startup code that initializes Firebase correctly. If any one of those pieces is missing, the app may build while Analytics still does nothing.

Register the App in Firebase

Start in the Firebase console by creating a project or opening an existing one. Add an Apple app to that project and make sure the bundle identifier matches the Xcode target exactly.

After registration, download GoogleService-Info.plist and add it to the Xcode project. Make sure it belongs to the main app target so it is bundled into the application.

If the bundle ID in Firebase and the bundle ID in Xcode do not match, Analytics initialization will not behave correctly.

Add the SDK in Xcode

On Apple platforms, the standard installation path is Swift Package Manager. Add the Firebase iOS SDK package and include the Analytics product for the correct target.

After that, initialize Firebase at startup.

For a UIKit app:

swift
1import UIKit
2import FirebaseCore
3
4@main
5class AppDelegate: UIResponder, UIApplicationDelegate {
6    func application(
7        _ application: UIApplication,
8        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
9    ) -> Bool {
10        FirebaseApp.configure()
11        return true
12    }
13}

For a SwiftUI app:

swift
1import SwiftUI
2import FirebaseCore
3
4class AppDelegate: NSObject, UIApplicationDelegate {
5    func application(
6        _ application: UIApplication,
7        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
8    ) -> Bool {
9        FirebaseApp.configure()
10        return true
11    }
12}
13
14@main
15struct DemoApp: App {
16    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
17
18    var body: some Scene {
19        WindowGroup {
20            ContentView()
21        }
22    }
23}

Without FirebaseApp.configure(), the SDK is present but not initialized.

Log a Test Event

After startup is configured, log a test event so you can verify that the integration is active.

swift
1import FirebaseAnalytics
2
3Analytics.logEvent("purchase_preview", parameters: [
4    "item_id": "sku_123",
5    "price": 19.99
6])

If the app runs and this event is accepted, the client-side integration is working.

Use Debug Mode During Setup

Firebase Analytics reports are not always visible in the console immediately, so debug mode matters during integration.

A common Xcode setup is to add the launch argument -FIRDebugEnabled to the scheme and then run the app from Xcode. The debug console will show Firebase-related logging and helps confirm that Analytics is initialized and event collection is active.

This is much better than waiting for standard dashboard reports during first-time setup.

Watch for Analytics Collection Controls

Installing the SDK is not the same thing as collecting analytics right away. Collection may be influenced by:

  • app code that disables analytics explicitly
  • Info.plist settings that alter collection behavior
  • privacy or consent flows that delay activation

If your app asks for consent before enabling analytics, make sure the collection state changes only after that decision is complete.

A Practical Verification Flow

A reliable setup sequence is:

  1. register the iOS app in Firebase
  2. add GoogleService-Info.plist to the correct target
  3. add the Firebase Analytics SDK in Xcode
  4. call FirebaseApp.configure() at startup
  5. log a test event
  6. run with -FIRDebugEnabled and inspect the console

This usually separates integration mistakes from reporting delays quickly.

Common Pitfalls

The most common mistake is a bundle identifier mismatch between Firebase and the Xcode target.

Another issue is adding GoogleService-Info.plist to the project but not to the right target membership, so the file never gets bundled into the app.

People also expect the Firebase console's normal reports to update instantly during setup. Use debug mode and test events first.

Finally, do not ignore analytics collection settings or consent logic. The SDK can be installed correctly while event collection is still intentionally off.

Summary

  • Register the iOS app in Firebase with the exact bundle identifier used by Xcode.
  • Add GoogleService-Info.plist to the app target.
  • Install the Firebase Analytics SDK through Swift Package Manager.
  • Call FirebaseApp.configure() during app startup.
  • Use a test event and -FIRDebugEnabled to verify the integration before relying on dashboard reports.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.