Add Firebase to your Apple project

Prerequisites

  • Install the following:

    • Xcode 16.2 or later
  • Make sure that your project meets these requirements:

    • Your project must target these platform versions or later:
      • iOS 13
      • macOS 10.15
      • tvOS 13
      • watchOS 7
  • Set up a physical Apple device or use a simulator to run your app.

    Do you want to use Cloud Messaging ?

    For Cloud Messaging on Apple platforms, here are the prerequisites:

    • Set up a physical Apple device .
    • Obtain an Apple Push Notification Authentication Key for your Apple Developer account .
    • Enable Push Notifications in Xcode under App > Capabilities.

If you don't already have an Xcode project and just want to try out a Firebase product, you can download one of our quickstart samples .

Step 1: Create a Firebase project

Before you can add Firebase to your Apple app, you need to create a Firebase project to connect to your app. Visit Understand Firebase Projects to learn more about Firebase projects.

Step 2: Register your app with Firebase

To use Firebase in your Apple app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.

  1. Go to the Firebase console .

  2. In the center of the project overview page, click the iOS+icon to launch the setup workflow.

    If you've already added an app to your Firebase project, click Add appto display the platform options.

  3. Enter your app's bundle ID in the bundle IDfield.

    What's a bundle ID, and where do you find it?

    • A bundle ID uniquely identifies an application in Apple's ecosystem.

    • Find your bundle ID: open your project in Xcode, select the top-level app in the project navigator, then select the Generaltab.

      The value of the Bundle Identifierfield is the bundle ID (for example, com.yourcompany.yourproject ).

    • Be aware that the bundle ID value is case-sensitive, and it cannot be changed for this Firebase app after it's registered with your Firebase project.

  • (Optional) Enter other app information: App nicknameand App Store ID.

    How are the App nickname and the App Store ID used within Firebase?

  • Click Register app.

  • Step 3: Add a Firebase configuration file

    1. Click Download GoogleService-Info.plistto obtain your app's Firebase config file ( GoogleService-Info.plist ).

      What do you need to know about this config file?

      • The Firebase config file contains unique, but non-secret identifiers for your project and app. To learn more about this config file, visit Understand Firebase Projects .

      • You can download your Firebase config file again at any time.

      • Make sure the config file name is not appended with additional characters, like (2) .

    2. Move your config file into the root of your Xcode project. If prompted, select to add the config file to all targets.

    If you have multiple bundle IDs in your project, you must associate each bundle ID with a registered app in the Firebase console so that each app can have its own GoogleService-Info.plist file.

    Step 4: Add Firebase SDKs to your app

    Use Swift Package Manager to install and manage Firebase dependencies.

    1. In Xcode, with your app project open, navigate to File > Add Packages .
    2. When prompted, add the Firebase Apple platforms SDK repository:
    3. https://github.com/firebase/firebase-ios-sdk
    4. Select the SDK version that you want to use.
    5. Choose the Firebase libraries you want to use.

      If Google Analytics is enabled in your Firebase project, make sure to add FirebaseAnalytics . This provides all analytics features. You can also select individual features; refer to our FAQ on the latest organization of modules in the Google Analytics for Firebase SDK .

    When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.

    Step 5: Initialize Firebase in your app

    The final step is to add initialization code to your application. You may have already done this as part of adding Firebase to your app. If you're using a quickstart sample project , this has been done for you.

    1. Import the FirebaseCore module in your UIApplicationDelegate , as well as any other Firebase modules your app delegate uses. For example, to use Cloud Firestore and Authentication :

      SwiftUI

       import 
        
       SwiftUI 
       import 
        
       FirebaseCore 
       import 
        
       FirebaseFirestore 
       import 
        
       FirebaseAuth 
       // ... 
        
      

      Swift

       import 
        
       FirebaseCore 
       import 
        
       FirebaseFirestore 
       import 
        
       FirebaseAuth 
       // ... 
        
      

      Objective-C

       @import 
        
       FirebaseCore 
       ; 
       @import 
        
       FirebaseFirestore 
       ; 
       @import 
        
       FirebaseAuth 
       ; 
       // ... 
        
      
    2. Configure a FirebaseApp shared instance in your app delegate's application(_:didFinishLaunchingWithOptions:) method:

      SwiftUI

       // Use Firebase library to configure APIs 
       FirebaseApp 
       . 
       configure 
       () 
      

      Swift

       // Use Firebase library to configure APIs 
       FirebaseApp 
       . 
       configure 
       () 
      

      Objective-C

       // Use Firebase library to configure APIs 
       [ 
       FIRApp 
        
       configure 
       ]; 
      
    3. If you're using SwiftUI, you must create an application delegate and attach it to your App struct via UIApplicationDelegateAdaptor or NSApplicationDelegateAdaptor . You must also disable app delegate swizzling. For more information, see the SwiftUI instructions .

      SwiftUI

       @ 
       main 
       struct 
        
       YourApp 
       : 
        
       App 
        
       { 
        
       // register app delegate for Firebase setup 
        
       @ 
       UIApplicationDelegateAdaptor 
       ( 
       AppDelegate 
       . 
       self 
       ) 
        
       var 
        
       delegate 
        
       var 
        
       body 
       : 
        
       some 
        
       Scene 
        
       { 
        
       WindowGroup 
        
       { 
        
       NavigationView 
        
       { 
        
       ContentView 
       () 
        
       } 
        
       } 
        
       } 
       } 
        
      
    4. If you've included the Firebase SDK for Google Analytics , you can run your app to send verification to the Firebase console that you've successfully installed Firebase.

    That's it! You can skip ahead to the next steps .

    If you're having trouble getting set up, though, visit the Apple platforms troubleshooting & FAQ .

    Available libraries

    This section lists the Firebase products supported for Apple platforms. Learn more about these Firebase Apple platform libraries:

    Service or Product Pods SwiftPM Libraries Add Analytics?
    pod 'Google-Mobile-Ads-SDK' N/A
    pod 'FirebaseAI' FirebaseAI
    pod 'FirebaseAnalytics' FirebaseAnalytics
    pod 'FirebaseAppCheck' FirebaseAppCheck
    pod 'FirebaseAppDistribution' FirebaseAppDistribution
    pod 'FirebaseAuth' FirebaseAuth
    pod 'FirebaseFirestore' FirebaseFirestore
    pod 'FirebaseFunctions' FirebaseFunctions
    pod 'FirebaseMessaging' FirebaseMessaging
    pod 'FirebaseStorage' FirebaseStorage
    pod 'FirebaseCrashlytics' FirebaseCrashlytics
    N/A FirebaseDataConnect
    pod 'FirebaseDynamicLinks' FirebaseDynamicLinks
    pod 'FirebaseInAppMessaging' FirebaseInAppMessaging
    (required)
    pod 'FirebaseInstallations' FirebaseInstallations
    pod 'FirebaseMLModelDownloader' FirebaseMLModelDownloader
    pod 'FirebasePerformance' FirebasePerformance
    pod 'FirebaseDatabase' FirebaseDatabase
    pod 'FirebaseRemoteConfig' FirebaseRemoteConfig

    1 Firebase AI Logic was formerly called " Vertex AI in Firebase " with the pod pod 'FirebaseVertexAI' and SwiftPM Library FirebaseVertexAI .

    Integrate without using Swift Package Manager

    If you don't want to use Swift Package Manager, you can still take advantage of the Firebase SDKs by using CocoaPods or by importing the frameworks directly.

    CocoaPods

    Learn more about CocoaPods integration in our guide .

    Frameworks

    In addition to supporting the iOS platform, the zip now includes .xcframework files. For details, see the Firebase Apple platforms SDK README on GitHub .

    1. Download the framework SDK zip . This is a ~200MB file and might take some time to download.

    2. Unzip the file, and then integrate the frameworks that you want to include in your app.

      You can find integration instructions in either of the following places:

      For information regarding framework versions or dependencies, refer to the METADATA.md file within the downloaded zip distribution.

    3. Add the -ObjC linker flag in your Other Linker Settings in your target's build settings.

    Next steps

    Learn about Firebase:

    Add Firebase services to your app:

    Design a Mobile Site
    View Site in Mobile | Classic
    Share by: