Add Firebase to your C++ project Stay organized with collections Save and categorize content based on your preferences.
Power up your C++ games with our Firebase C++ SDKs which provide a C++interface on top of Firebase SDKs.
Access Firebase entirely from your C++ code, without having to write anyplatform-native code. The Firebase SDK also translates many language-specificidioms used by Firebase into an interface more familiar to C++ developers.
Find out more information about powering up your games with Firebase at ourFirebase games page.
Learn whichFirebase products theFirebaseC++ SDK supports.Already added Firebase to your C++ project? Make sure that you're using thelatest version of theFirebaseC++ SDK.
Select a platform tab below to display platform-specific instructions in this guide.
If you're releasing your game on both iOS and Android platforms: You can register one build target of your C++ project now, then return to the setup workflow later to register the other build target, too.
Prerequisites
Install the following:
- Xcode 16.2 or later
- CocoaPods 1.12.0 or later
Make sure that your project targets the following platform versions or later:
- iOS 13
- tvOS 13
Set up a physical device or use the simulator to run your app.
Do you want to useCloud Messaging?
ForCloud Messaging on Apple platforms, here are the prerequisites:
- Set up aphysical Apple device.
- Obtain an Apple Push Notification Authentication Key for yourApple Developer account.
- Enable Push Notifications in Xcode underApp > Capabilities.
Sign into Firebase using yourGoogle account.
Step 2: Create a Firebase project
Before you can add Firebase to your C++ project, you need to create a Firebaseproject to connect to your C++ project. VisitUnderstand Firebase Projects to learn more aboutFirebase projects.
View instructions to create a Firebase project
New to Firebase or Cloud
Follow these steps if you're new to Firebase orGoogle Cloud.
You can also follow these steps if you want to create a wholly new Firebase project (and its underlyingGoogle Cloud project).
- Sign into theFirebase console.
- Click the button to create a new Firebase project.
In the text field, enter aproject name.
If you're part of aGoogle Cloud org, you can optionally select which folder you create your project in.
Your project name is used as a display name in Firebase interfaces, and Firebase auto-creates a unique project ID based on this project name. Note that you can optionally click theEdit icon now to set your preferred project ID, but you cannot change this ID after project creation. Learn abouthow Firebase uses the project ID.- If prompted, review and accept theFirebase terms, then clickContinue.
- (Optional) Enable AI assistance in theFirebase console (called "Gemini in Firebase"), which can help you get started and streamline your development process.
(Optional) Set upGoogle Analytics for your project, which enables an optimal experience using these Firebase products:Firebase A/B Testing,Cloud Messaging,Crashlytics,In-App Messaging, andRemote Config (includingPersonalization).
Either select an existingGoogle Analytics account or create a new account. If you create a new account, select yourAnalytics reporting location, then accept the data sharing settings andGoogle Analytics terms for your project.
You can always set upGoogle Analytics later in theIntegrations tab of your Project settings.- ClickCreate project.
Firebase creates your project, provisions some initial resources, and enables important APIs. When the process completes, you'll be taken to the overview page for your Firebase project in theFirebase console.
Existing Cloud project
Follow these steps if you want to start using Firebase with an existingGoogle Cloud project. Learn more about"adding Firebase" to an existingGoogle Cloud project.
- Sign into theFirebase console with the account that gives you access to the existingGoogle Cloud project.
- Click the button to create a new Firebase project.
- At the bottom of the page, clickAdd Firebase to Google Cloud project.
- In the text field, start entering theproject name of the existing project, and then select the project from the displayed list.
- ClickOpen project.
- If prompted, review and accept theFirebase terms, then clickContinue.
- (Optional) Enable AI assistance in theFirebase console (called "Gemini in Firebase"), which can help you get started and streamline your development process.
(Optional) Set upGoogle Analytics for your project, which enables an optimal experience using these Firebase products:Firebase A/B Testing,Cloud Messaging,Crashlytics,In-App Messaging, andRemote Config (includingPersonalization).
Either select an existingGoogle Analytics account or create a new account. If you create a new account, select yourAnalytics reporting location, then accept the data sharing settings andGoogle Analytics terms for your project.
You can always set upGoogle Analytics later in theIntegrations tab of your Project settings.- ClickAdd Firebase.
Firebaseadds Firebase to your existing project. When the process completes, you'll be taken to the overview page for your Firebase project in theFirebase console.
Step 3: Register your app with Firebase
To use Firebase in your Apple app, you need to register your app with yourFirebase project. Registering your app is often called "adding" your app to yourproject.
Note: Check out ourbest practicesfor adding apps to a Firebase project, including how to handle multiplevariants.Go to theFirebase console.
In the center of the project overview page, click theiOS+ iconto launch the setup workflow.
If you've already added an app to your Firebase project, clickAdd appto display the platform options.
Enter your app's bundle ID in thebundle ID field.
What's a bundle ID, and where do you find it?
Make sure to enter the bundle ID that your app is actually using. The bundle ID value is case-sensitive, and it cannot be changed for this Firebase Apple app after it's registered with your Firebase project.Abundle ID uniquely identifies an application in Apple's ecosystem.
Find your bundle ID: open your project in Xcode, select thetop-level app in the project navigator, then select theGeneral tab.
The value of theBundle Identifier field is the bundle ID(for example,
com.yourcompany.yourproject
).Be aware that the bundle ID value is case-sensitive, and it cannot bechanged for this Firebase app after it's registered with yourFirebase project.
(Optional) Enter other app information:App nickname andApp Store ID.
How are theApp nickname and theApp Store ID used within Firebase?
App nickname: An internal, convenience identifier that is only visibleto you in theFirebase console
App Store ID: Used byFirebase Dynamic Links toredirect users to your App Store pageand byGoogle Analytics toimport conversion events intoGoogle Ads.If your app doesn't yet have an App Store ID, you can add the ID laterin yourProjectsettings.
ClickRegister app.
Step 4: Add the Firebase configuration file
ClickDownload GoogleService-Info.plist to obtain your Firebase Apple platforms config file.
What do you need to know about this config file?
The Firebase config file contains unique, but non-secret identifiers foryour project and app. To learn more about this config file, visitUnderstand FirebaseProjects.
You can download yourFirebase configfile again at any time.
Make sure the config file name is not appended with additional characters,like
(2)
.
Open your C++ project in an IDE, then drag your config file into the rootof your C++ project.
If prompted, select to add the config file to all targets.
You're done with set up tasks in theFirebase console. Continue toAdd Firebase C++ SDKs below.
Step 5: Add Firebase C++ SDKs
The steps in this section are an example of how to addsupported Firebase products to your FirebaseC++ project.
Each Firebase product has its own set ofdependencies. Be sure to add all the listed dependencies for the desired Firebase product to your Podfile and C++ project.Download theFirebaseC++ SDK, then unzip the SDK somewhere convenient.
TheFirebaseC++ SDK is not platform-specific, but it does containplatform-specific libraries.
Add Firebasepods from the unzipped SDK.
Create a Podfile if you don't already have one:
cdyour-app-directory
pod init
To your Podfile, add the Firebase pods that you want to use in your app.
Analytics enabled
# Add the Firebase pod forGoogle Analyticspod'FirebaseAnalytics'
# Add the pods for any other Firebase products you want to use in your app# For example, to useFirebase Authentication andFirebase Realtime Databasepod'FirebaseAuth'pod'FirebaseDatabase'Analytics not enabled
# Add the pods for the Firebase products you want to use in your app# For example, to useFirebase Authentication andFirebase Realtime Databasepod'FirebaseAuth'pod'FirebaseDatabase'
Install the pods, then open the
.xcworkspace
file in Xcode.pod install
openyour-app.xcworkspace
Add Firebaseframeworks from the unzippedSDK.
The easiest way to add these frameworks is usually to drag them from a
Finder
window directly into Xcode'sProject Navigator pane (thefar-left pane, by default; or click the file icon in the top-left of Xcode).Add the Firebase C++ framework
firebase.framework
, which isrequired to use any Firebase product.Add the framework for each Firebase product that you want to use. For example, to useFirebase Authentication, add
firebase_auth.framework
.
Back in theFirebase console, in the setup workflow, clickNext.
If you addedAnalytics, run your app to send verification to Firebasethat you've successfully integrated Firebase. Otherwise, you can skip thisverification step.
Your device logs will display the Firebase verification that initializationis complete. If you ran your app on an emulator that has network access,theFirebase console notifies you that your app connection is complete.
You’re all set! Your C++ app is registered and configured to use Firebaseproducts.
Note: If you're also releasing your game on Android, return to yourFirebase project overview page, then register theAndroid build target of your C++ projectwith this same Firebase project.Find Android setup instructions on theAndroid version of this setup page.
Available libraries
Learn more about the C++ Firebase libraries in thereference documentation and in our open-source SDKrelease onGitHub.
Available libraries for Apple platforms
Note that C++ libraries for Android are listed on theAndroid version of thissetup page.
Each Firebase product has different dependencies. Be sure to add all thelisted dependencies for the desired Firebase product to your Podfile andC++ project.
Each Firebase product may only support a selection of Apple OS platforms (iOS,tvOS, etc.). Check which platforms are supported by each library inLearn more about C++ and Firebase.
You no longer need to add the iOS podFirebase/Core
. This SDK included the Firebase SDK forGoogle Analytics. Now, to useAnalytics (or any of the Firebase products that require or recommend the use ofAnalytics), you need to explicitly add theAnalytics pod:Firebase/Analytics
.Firebase product | Frameworks and Pods |
---|---|
AdMob | (required)firebase.framework firebase_admob.framework (required) firebase_analytics.framework pod 'FirebaseAdMob', '12.2.0' (required) pod 'FirebaseAnalytics', '12.2.0' |
Analytics | (required)firebase.framework firebase_analytics.framework pod 'FirebaseAnalytics', '12.2.0' |
App Check | (required)firebase.framework firebase_app_check.framework pod 'FirebaseAppCheck', '12.2.0' |
Authentication | (required)firebase.framework firebase_auth.framework pod 'FirebaseAuth', '12.2.0' |
Cloud Firestore | (required)firebase.framework firebase_firestore.framework firebase_auth.framework pod 'FirebaseFirestore', '12.2.0' pod 'FirebaseAuth', '12.2.0' |
Cloud Functions | (required)firebase.framework firebase_functions.framework pod 'FirebaseFunctions', '12.2.0' |
Cloud Messaging | (required)firebase.framework firebase_messaging.framework (recommended) firebase_analytics.framework pod 'FirebaseMessaging', '12.2.0' (recommended) pod 'FirebaseAnalytics', '12.2.0' |
Cloud Storage | (required)firebase.framework firebase_storage.framework pod 'FirebaseStorage', '12.2.0' |
Dynamic Links | (required)firebase.framework firebase_dynamic_links.framework (recommended) firebase_analytics.framework pod 'FirebaseDynamicLinks', '12.2.0' (recommended) pod 'FirebaseAnalytics', '12.2.0' |
Realtime Database | (required)firebase.framework firebase_database.framework pod 'FirebaseDatabase', '12.2.0' |
Remote Config | (required)firebase.framework firebase_remote_config.framework (recommended) firebase_analytics.framework pod 'FirebaseRemoteConfig', '12.2.0' (recommended) pod 'FirebaseAnalytics', '12.2.0' |
Additional information for mobile setup
Method swizzling
On iOS, some application events (such as opening URLs and receivingnotifications) require your application delegate to implement specificmethods. For example, receiving a notification might require your applicationdelegate to implementapplication:didReceiveRemoteNotification:
. Becauseeach iOS application has its own app delegate, Firebase usesmethod swizzling, which allows the replacement of one method with another,to attach its own handlers in addition to any that you might have implemented.
TheDynamic Links andCloud Messaging libraries needto attach handlers to the application delegate using method swizzling. Ifyou're using any of these Firebase products, at load time, Firebase willidentify yourAppDelegate
class and swizzle the required methods onto it,chaining a call back to your existing method implementation.
Set up a desktop workflow (beta)
Caution:FirebaseC++ SDK desktop support is abeta feature. This feature isintended only for workflows during the development of your game, not forpublicly shipping code.When you're creating a game, it's often much easier to test your game on desktopplatforms first, then deploy and test on mobile devices later in development. Tosupport this workflow, we provide asubset of theFirebaseC++ SDKs which can run onWindows, macOS, Linux, and from within the C++ editor.
For desktop workflows, you need to complete the following:
- Configure your C++ project for CMake.
- Create a Firebase project
- Register your app (iOS or Android) with Firebase
- Add a mobile-platform Firebase configuration file
Create adesktop version of the Firebase configuration file:
If you added the Android
google-services.json
file — When you runyour app, Firebase locates thismobile file, then automaticallygenerates adesktop Firebase config file(google-services-desktop.json
).If you added the iOS
GoogleService-Info.plist
file — Before you runyour app, you need to convert thismobile file to adesktop Firebaseconfig file. To convert the file, run the following command from the samedirectory as yourGoogleService-Info.plist
file:generate_xml_from_google_services_json.py --plist -i GoogleService-Info.plist
This desktop config file contains the C++ project ID that you entered intheFirebase console setup workflow. VisitUnderstand Firebase Projectsto learn more about config files.
Add Firebase SDKs to your C++ project.
The steps below serve as an example of how to add anysupported Firebase product toyour C++ project. In this example, we walk through addingFirebase Authentication andFirebase Realtime Database.
Set your
FIREBASE_CPP_SDK_DIR
environment variable to the location ofthe unzippedFirebaseC++ SDK.To your project's
CMakeLists.txt
file, add the following content,including thelibraries forthe Firebase products that you want to use. For example, to useFirebase Authentication andFirebase Realtime Database:# Add Firebase libraries to the target using the function from the SDK.add_subdirectory(${FIREBASE_CPP_SDK_DIR}bin/EXCLUDE_FROM_ALL)# The Firebase C++ library `firebase_app` is required,# and it must always be listed last.# Add the Firebase SDKs for the products you want to use in your app# For example, to useFirebase Authentication andFirebase Realtime Databaseset(firebase_libsfirebase_authfirebase_databasefirebase_app)target_link_libraries(${target_name}"${firebase_libs}")
Run your C++ app.
Available libraries (desktop)
TheFirebaseC++ SDK includesdesktop workflow supportfor a subset of features, enabling certain parts of Firebase to be used instandalone desktop builds on Windows, macOS, and Linux.
Caution:FirebaseC++ SDK desktop support is abeta feature. This featureis intended only for workflows during the development of your game, not forpublicly shipping code.Firebase product | Library references (using CMake) |
---|---|
App Check | firebase_app_check (required) firebase_app |
Authentication | firebase_auth (required) firebase_app |
Cloud Firestore | firebase_firestore firebase_auth firebase_app |
Cloud Functions | firebase_functions (required) firebase_app |
Cloud Storage | firebase_storage (required) firebase_app |
Realtime Database | firebase_database (required) firebase_app |
Remote Config | firebase_remote_config (required) firebase_app |
Firebase provides the remaining desktop libraries as stub (non-functional)implementations for convenience when building for Windows, macOS, and Linux.Therefore, you don't need to conditionally compile code to target the desktop.
Realtime Database desktop
TheRealtime Database SDK for desktop uses REST to access your database, so you mustdeclare the indexes thatyou use withQuery::OrderByChild()
on desktop or your listeners will fail.
Additional information for desktop setup
Windows libraries
For Windows, library versions are provided based on the following:
- Build platform: 32-bit (x86) vs 64-bit (x64) mode
- Windows runtime environment: Multithreaded / MT vs Multithreaded DLL /MD
- Target: Release vs Debug
Note that the following libraries were tested using Visual Studio 2015 and 2017.
When building C++ desktop apps on Windows, link the following Windows SDKlibraries to your project. Consult your compiler documentation for moreinformation.
Firebase C++ Library | Windows SDK library dependencies |
---|---|
App Check | advapi32, ws2_32, crypt32 |
Authentication | advapi32, ws2_32, crypt32 |
Cloud Firestore | advapi32, ws2_32, crypt32, rpcrt4, ole32, shell32 |
Cloud Functions | advapi32, ws2_32, crypt32, rpcrt4, ole32 |
Cloud Storage | advapi32, ws2_32, crypt32 |
Realtime Database | advapi32, ws2_32, crypt32, iphlpapi, psapi, userenv |
Remote Config | advapi32, ws2_32, crypt32, rpcrt4, ole32 |
macOS libraries
For macOS (Darwin), library versions are provided for the 64-bit (x86_64)platform. Frameworks are also provided for your convenience.
Note that the macOS libraries have been tested using Xcode16.2.
When building C++ desktop apps on macOS, link the following to your project:
pthread
system libraryCoreFoundation
macOS system frameworkFoundation
macOS system frameworkSecurity
macOS system frameworkGSS
macOS system frameworkKerberos
macOS system frameworkSystemConfiguration
macOS system framework
Consult your compiler documentation for more information.
Linux libraries
For Linux, library versions are provided for 32-bit (i386) and 64-bit (x86_64)platforms.
Note that the Linux libraries were tested using GCC 4.8.0, GCC 7.2.0, andClang 5.0 on Ubuntu.
When building C++ desktop apps on Linux, link thepthread
system library toyour project. Consult your compiler documentation for more information. Ifyou're building with GCC 5 or later, define-D_GLIBCXX_USE_CXX11_ABI=0
.
Next steps
Exploresample Firebase apps.
Explore theopen source SDK inGitHub.
Prepare to launch your app:
- Set upbudgetalertsfor your project in theGoogle Cloud console.
- Monitor theUsage and billingdashboard in theFirebase console to get an overall picture of your project'susage across multiple Firebase services.
- Review theFirebase launch checklist.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-07 UTC.