Prerequisites
Install the following:
- Xcode 11.0 or later
- CocoaPods 1.9.0 or later
Make sure that your project meets these requirements:
- Your project must target iOS 10 or later.
Set up a physical iOS device or use the iOS simulator to run your app.
- Sign into Firebase using your Google account.
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 iOS app, you need to create a Firebase project to connect to your iOS app. Visit Understand Firebase Projects to learn more about Firebase projects.
Step 2: Register your app with Firebase
After you have a Firebase project, you can add your iOS app to it.
Visit Understand Firebase Projects to learn more about best practices and considerations for adding apps to a Firebase project, including how to handle multiple build variants.
Go to the Firebase console.
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 app to display the platform options.
Enter your app's bundle ID in the iOS bundle ID field.
(Optional) Enter other app information: App nickname and App Store ID.
Click Register app.
Step 3: Add a Firebase configuration file
Click Download GoogleService-Info.plist to obtain your Firebase iOS config file (
GoogleService-Info.plist).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
We recommend using CocoaPods to install the Firebase libraries. However, if you'd rather not use CocoaPods, you can integrate the SDK frameworks directly or use the Swift Package Manager (beta).
Are you using one of the quickstart samples? The Xcode project and Podfile (with pods) are already present, but you'll still need to add your Firebase configuration file and install the pods.
Create a Podfile if you don't already have one:
cd your-project-directory
pod init
To your Podfile, add the Firebase pods that you want to use in your app.
You can add any of the supported Firebase products to your iOS app.
Analytics enabled
# Add the Firebase pod for Google Analytics pod 'Firebase/Analytics'
# Add the pods for any other Firebase products you want to use in your app # For example, to use Firebase Authentication and Cloud Firestore pod 'Firebase/Auth' pod 'Firebase/Firestore'Analytics not enabled
# Add the pods for the Firebase products you want to use in your app # For example, to use Firebase Authentication and Cloud Firestore pod 'Firebase/Auth' pod 'Firebase/Firestore'
Install the pods, then open your
.xcworkspacefile to see the project in Xcode:pod install
open your-project.xcworkspace
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.
- Import the Firebase module in your
UIApplicationDelegate:Swift
import Firebase
Objective-C
@import Firebase;
- Configure a
FirebaseAppshared instance, typically in your app'sapplication:didFinishLaunchingWithOptions:method:Swift
// Use Firebase library to configure APIs FirebaseApp.configure()
Objective-C
// Use Firebase library to configure APIs [FIRApp configure];
- If you've included Firebase 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.
Available pods
This section lists the Firebase products supported for iOS and their pods. Learn more about these Firebase iOS libraries:
Firebase iOS SDK GitHub repo
| Service or Product | Pods | Add Analytics? |
|---|---|---|
| AdMob | pod 'Google-Mobile-Ads-SDK' |
|
| Analytics | pod 'Firebase/Analytics' |
|
| App Distribution | pod 'Firebase/AppDistribution' |
|
| Authentication | pod 'Firebase/Auth' |
|
| Cloud Firestore | pod 'Firebase/Firestore' |
|
| Cloud Functions for Firebase Client SDK | pod 'Firebase/Functions' |
|
| Cloud Messaging | pod 'Firebase/Messaging' |
|
| Cloud Storage | pod 'Firebase/Storage' |
|
| Firebase Crashlytics | pod 'Firebase/Crashlytics' |
|
| Dynamic Links | pod 'Firebase/DynamicLinks' |
|
| In-App Messaging | pod 'Firebase/InAppMessaging' |
(required) |
| Firebase ML Vision APIs | pod 'Firebase/MLVision' |
|
| Firebase ML Custom Model APIs | pod 'Firebase/MLModelInterpreter' |
|
| Performance Monitoring | pod 'Firebase/Performance' |
|
| Realtime Database | pod 'Firebase/Database' |
|
| Remote Config | pod 'Firebase/RemoteConfig' |
Integrate without CocoaPods
If you don't want to use Cocoapods, you can still take advantage of the Firebase SDKs by importing the frameworks directly or using the Swift Package Manager.
Frameworks
In addition to supporting the iOS platform, the zip now includes .xcframework files that add community-based Catalyst support. For details, see the Firebase iOS SDK README on GitHub .
Download the framework SDK zip. This is a ~200MB file and might take some time to download.
Unzip the file, then review the
READMEfor the Frameworks that you want to include in your app.Add the
ObjClinker flag in yourOther Linker Settingsin your target's build settings.
Swift Package Manager
Swift Package Manager support is currently in beta. Follow the documentation on GitHub, and file any feedback to the GitHub issue tracker.
Next steps
Learn about Firebase:
Visit Understand Firebase Projects to learn more about Firebase projects and best practices for projects.
Explore sample Firebase apps.
Get hands-on experience with the Firebase iOS Codelab.
Explore the open source code in GitHub.
Prepare to launch your app:
- Set up budget alerts for your project in the GCP console.
- Monitor your Usage and billing dashboard in the Firebase console.
- Review the Firebase launch checklist.
Add Firebase services to your app:
Gain insights on user behavior with Analytics.
Set up user authentication with Authentication.
Store data, like user information, with Cloud Firestore or Realtime Database.
Store files, like photos and videos, with Cloud Storage.
Trigger backend code that runs in a secure environment with Cloud Functions.
Send notifications with Cloud Messaging.
Find out when and why your app is crashing with Crashlytics.