Firebase 将于 5 月 10 日重返 Google I/O 大会!立即报名

Aggiungi Firebase al tuo progetto C++

Potenzia i tuoi giochi C++ con i nostri SDK Firebase C++ che forniscono un'interfaccia C++ oltre agli SDK Firebase.

Accedi a Firebase interamente dal tuo codice C++, senza dover scrivere alcun codice nativo della piattaforma. L'SDK di Firebase traduce anche molti idiomi specifici della lingua utilizzati da Firebase in un'interfaccia più familiare agli sviluppatori C++.

Scopri ulteriori informazioni su come potenziare i tuoi giochi con Firebase nella nostra pagina dei giochi Firebase .

Hai già aggiunto Firebase al tuo progetto C++? Assicurati di utilizzare la versione più recente di Firebase C++ SDK .

Prerequisiti

  • Installa quanto segue:

    • Xcode 13.3.1 o successivo
    • CocoaPods 1.10.0 o successivo
  • Assicurati che il tuo progetto abbia come target le seguenti versioni della piattaforma o successive:

    • iOS 11
    • tv OS 12
  • Configura un dispositivo fisico o usa il simulatore per eseguire la tua app.

  • Accedi a Firebase utilizzando il tuo account Google.

Passaggio 2 : crea un progetto Firebase

Prima di poter aggiungere Firebase al tuo progetto C++, devi creare un progetto Firebase per connetterti al tuo progetto C++. Visita Capire i progetti Firebase per saperne di più sui progetti Firebase.

Passaggio 3 : registra la tua app con Firebase

Per utilizzare Firebase nella tua app Apple, devi registrare la tua app con il tuo progetto Firebase. La registrazione della tua app viene spesso chiamata "aggiunta" della tua app al tuo progetto.

  1. Vai alla console di Firebase .

  2. Al centro della pagina della panoramica del progetto, fai clic sull'icona iOS+ per avviare il flusso di lavoro di configurazione.

    Se hai già aggiunto un'app al tuo progetto Firebase, fai clic su Aggiungi app per visualizzare le opzioni della piattaforma.

  3. Inserisci l'ID bundle della tua app nel campo ID bundle .

  4. (Facoltativo) Inserisci altre informazioni sull'app: nickname dell'app e ID dell'App Store .

  5. Fai clic su Registra app .

Passaggio 4 : aggiungi il file di configurazione di Firebase

  1. Fai clic su Scarica GoogleService-Info.plist per ottenere il file di configurazione delle piattaforme Firebase Apple.

  2. Apri il tuo progetto C++ in un IDE, quindi trascina il tuo file di configurazione nella root del tuo progetto C++.

  3. Se richiesto, selezionare per aggiungere il file di configurazione a tutte le destinazioni.

Hai finito con le attività di configurazione nella console Firebase. Continua ad aggiungere SDK Firebase C++ di seguito.

Passaggio 5 : aggiungi gli SDK Firebase C++

I passaggi in questa sezione sono un esempio di come aggiungere prodotti Firebase supportati al tuo progetto Firebase C++.

  1. Scarica l' SDK Firebase C++ , quindi decomprimi l'SDK in un punto comodo.

    L'SDK Firebase C++ non è specifico della piattaforma, ma contiene librerie specifiche della piattaforma.

  2. Aggiungi i pod Firebase dall'SDK decompresso.

    1. Crea un Podfile se non ne hai già uno:

      cd your-app-directory
      pod init

    2. Al tuo Podfile, aggiungi i pod Firebase che desideri utilizzare nella tua app.

      Analisi abilitata

      # Add the Firebase pod for Google Analytics
      pod 'FirebaseAnalytics'
      # Add the pods for any other Firebase products you want to use in your app # For example, to use Firebase Authentication and Firebase Realtime Database pod 'FirebaseAuth' pod 'FirebaseDatabase'

      Analisi non abilitata

      # Add the pods for the Firebase products you want to use in your app
      # For example, to use Firebase Authentication and Firebase Realtime Database
      pod 'FirebaseAuth'
      pod 'FirebaseDatabase'
    3. Installa i pod, quindi apri il file .xcworkspace in Xcode.

      pod install
      open your-app.xcworkspace

  3. Aggiungi framework Firebase dall'SDK decompresso.

    Il modo più semplice per aggiungere questi framework è in genere trascinarli da una finestra Finder direttamente nel riquadro Project Navigator di Xcode (il riquadro all'estrema sinistra, per impostazione predefinita; oppure fare clic sull'icona del file in alto a sinistra di Xcode).

    1. Aggiungi il framework Firebase C++ firebase.framework , necessario per utilizzare qualsiasi prodotto Firebase.

    2. Aggiungi il framework per ogni prodotto Firebase che desideri utilizzare. Ad esempio, per utilizzare Firebase Authentication, aggiungi firebase_auth.framework .

  4. Tornando alla console Firebase, nel flusso di lavoro di configurazione, fai clic su Avanti .

  5. Se hai aggiunto Analytics, esegui la tua app per inviare la verifica a Firebase che hai integrato correttamente Firebase. Altrimenti, puoi saltare questo passaggio di verifica.

    I registri del tuo dispositivo mostreranno la verifica di Firebase che l'inizializzazione è stata completata. Se hai eseguito l'app su un emulatore con accesso alla rete, la console di Firebase ti avvisa che la connessione dell'app è completa.

È tutto pronto! La tua app C++ è registrata e configurata per utilizzare i prodotti Firebase.

Librerie disponibili

Scopri di più sulle librerie C++ Firebase nella documentazione di riferimento e nella nostra versione dell'SDK open source su GitHub .

Librerie disponibili per piattaforme Apple

Tieni presente che le librerie C++ per Android sono elencate nella versione Android di questa pagina di configurazione .

Ogni prodotto Firebase ha dipendenze diverse. Assicurati di aggiungere tutte le dipendenze elencate per il prodotto Firebase desiderato al tuo progetto Podfile e C++.

Ciascun prodotto Firebase può supportare solo una selezione di piattaforme del sistema operativo Apple (iOS, tvOS e così via). Controlla quali piattaforme sono supportate da ciascuna libreria in Ulteriori informazioni su C++ e Firebase .

Prodotto base fuoco Framework e pod
AdMob (richiesto) firebase.framework
firebase_admob.framework
(obbligatorio) firebase_analytics.framework

pod 'FirebaseAdMob', '10.6.0'
(obbligatorio) pod 'FirebaseAnalytics', '10.6.0'
Analitica (richiesto) firebase.framework
firebase_analytics.framework

pod 'FirebaseAnalytics', '10.6.0'
Autenticazione (richiesto) firebase.framework
firebase_auth.framework

pod 'FirebaseAuth', '10.6.0'
CloudFirestore (richiesto) firebase.framework
firebase_firestore.framework
firebase_auth.framework

pod 'FirebaseFirestore', '10.6.0'
pod 'FirebaseAuth', '10.6.0'
Funzioni cloud (richiesto) firebase.framework
firebase_functions.framework

pod 'FirebaseFunctions', '10.6.0'
Messaggi sulla nuvola (richiesto) firebase.framework
firebase_messaging.framework
(consigliato) firebase_analytics.framework

pod 'FirebaseMessaging', '10.6.0'
(consigliato) pod 'FirebaseAnalytics', '10.6.0'
Archiviazione cloud (richiesto) firebase.framework
firebase_storage.framework

pod 'FirebaseStorage', '10.6.0'
Collegamenti dinamici (richiesto) firebase.framework
firebase_dynamic_links.framework
(consigliato) firebase_analytics.framework

pod 'FirebaseDynamicLinks', '10.6.0'
(consigliato) pod 'FirebaseAnalytics', '10.6.0'
Database in tempo reale (richiesto) firebase.framework
firebase_database.framework

pod 'FirebaseDatabase', '10.6.0'
Configurazione remota (richiesto) firebase.framework
firebase_remote_config.framework
(consigliato) firebase_analytics.framework

pod 'FirebaseRemoteConfig', '10.6.0'
(consigliato) pod 'FirebaseAnalytics', '10.6.0'

Ulteriori informazioni per la configurazione mobile

Metodo frizzante

Su iOS, alcuni eventi dell'applicazione (come l'apertura di URL e la ricezione di notifiche) richiedono che il delegato dell'applicazione implementi metodi specifici. Ad esempio, la ricezione di una notifica potrebbe richiedere al delegato dell'applicazione di implementare application:didReceiveRemoteNotification: . Poiché ogni applicazione iOS ha il proprio delegato dell'app, Firebase utilizza il metodo swizzling , che consente la sostituzione di un metodo con un altro, per collegare i propri gestori oltre a quelli che potresti aver implementato.

Le librerie Dynamic Links e Cloud Messaging devono collegare i gestori al delegato dell'applicazione usando lo swizzling del metodo. Se stai utilizzando uno di questi prodotti Firebase, al momento del caricamento, Firebase identificherà la tua classe AppDelegate e vi inserirà i metodi richiesti, concatenando una chiamata all'implementazione del metodo esistente.

Configurare un flusso di lavoro desktop ( beta )

Quando crei un gioco, spesso è molto più semplice testarlo prima su piattaforme desktop, quindi distribuirlo e testarlo su dispositivi mobili in una fase successiva dello sviluppo. Per supportare questo flusso di lavoro, forniamo un sottoinsieme degli SDK Firebase C++ che possono essere eseguiti su Windows, macOS, Linux e dall'editor C++.

  1. Per i flussi di lavoro desktop, è necessario completare quanto segue:

    1. Configura il tuo progetto C++ per CMake.
    2. Crea un progetto Firebase
    3. Registra la tua app (iOS o Android) con Firebase
    4. Aggiungi un file di configurazione Firebase per piattaforma mobile
  2. Crea una versione desktop del file di configurazione di Firebase:

    • Se hai aggiunto il file Android google-services.json : quando esegui l'app, Firebase individua questo file mobile , quindi genera automaticamente un file di configurazione Firebase desktop ( google-services-desktop.json ).

    • Se hai aggiunto il file iOS GoogleService-Info.plist : prima di eseguire l'app, devi convertire questo file mobile in un file di configurazione Firebase desktop . Per convertire il file, esegui il seguente comando dalla stessa directory del tuo file GoogleService-Info.plist :

      generate_xml_from_google_services_json.py --plist -i GoogleService-Info.plist

    Questo file di configurazione desktop contiene l'ID progetto C++ che hai inserito nel flusso di lavoro di configurazione della console Firebase. Visita Capire i progetti Firebase per saperne di più sui file di configurazione.

  3. Aggiungi SDK Firebase al tuo progetto C++.

    I passaggi seguenti servono come esempio di come aggiungere qualsiasi prodotto Firebase supportato al tuo progetto C++. In questo esempio, passiamo attraverso l'aggiunta di Firebase Authentication e Firebase Realtime Database.

    1. Imposta la variabile di ambiente FIREBASE_CPP_SDK_DIR nella posizione dell'SDK Firebase C++ decompresso.

    2. Al file CMakeLists.txt del tuo progetto, aggiungi i seguenti contenuti, incluse le librerie per i prodotti Firebase che desideri utilizzare. Ad esempio, per utilizzare Firebase Authentication e Firebase 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 use Firebase Authentication and Firebase Realtime Database
      set(firebase_libs firebase_auth firebase_database firebase_app)
      target_link_libraries(${target_name} "${firebase_libs}")
      
  4. Esegui la tua app C++.

Librerie disponibili (desktop)

L'SDK Firebase C++ include il supporto del flusso di lavoro desktop per un sottoinsieme di funzionalità, consentendo l'utilizzo di determinate parti di Firebase in build desktop autonome su Windows, macOS e Linux.

Prodotto base fuoco Riferimenti alla libreria (utilizzando CMake)
Autenticazione firebase_auth
(obbligatorio) firebase_app
CloudFirestore firebase_firestore
firebase_auth
firebase_app
Funzioni cloud firebase_functions
(obbligatorio) firebase_app
Archiviazione cloud firebase_storage
(obbligatorio) firebase_app
Database in tempo reale firebase_database
(obbligatorio) firebase_app
Configurazione remota firebase_remote_config
(obbligatorio) firebase_app

Firebase fornisce le restanti librerie desktop come implementazioni stub (non funzionali) per comodità durante la compilazione per Windows, macOS e Linux. Pertanto, non è necessario compilare in modo condizionale il codice per indirizzare il desktop.

Desktop database in tempo reale

L'SDK di Realtime Database per desktop utilizza REST per accedere al tuo database, quindi devi dichiarare gli indici che utilizzi con Query::OrderByChild() sul desktop o i tuoi listener falliranno.

Ulteriori informazioni per la configurazione del desktop

Librerie Windows

Per Windows, le versioni della libreria vengono fornite in base a quanto segue:

  • Piattaforma di compilazione: modalità a 32 bit (x86) rispetto a 64 bit (x64).
  • Ambiente di runtime Windows: Multithread / MT vs DLL multithread / MD
  • Obiettivo: Rilascio vs Debug

Tieni presente che le seguenti librerie sono state testate utilizzando Visual Studio 2015 e 2017.

Quando crei app desktop C++ in Windows, collega le seguenti librerie di Windows SDK al tuo progetto. Consultare la documentazione del compilatore per ulteriori informazioni.

Libreria Firebase C++ Dipendenze della libreria di Windows SDK
Autenticazione advapi32, ws2_32, crypt32
CloudFirestore advapi32, ws2_32, crypt32, rpcrt4, ole32, shell32
Funzioni cloud advapi32, ws2_32, crypt32, rpcrt4, ole32
Archiviazione cloud advapi32, ws2_32, crypt32
Database in tempo reale advapi32, ws2_32, crypt32, iphlpapi, psapi, userenv
Configurazione remota advapi32, ws2_32, crypt32, rpcrt4, ole32

librerie macOS

Per macOS (Darwin), vengono fornite le versioni della libreria per la piattaforma a 64 bit (x86_64). I framework sono forniti anche per tua comodità.

Si noti che le librerie macOS sono state testate utilizzando Xcode 13.3.1.

Quando crei app desktop C++ su macOS, collega quanto segue al tuo progetto:

  • libreria di sistema pthread
  • Struttura del sistema macOS CoreFoundation
  • Framework di sistema macOS Foundation
  • Struttura del sistema macOS Security
  • Struttura del sistema macOS GSS
  • Framework di sistema macOS Kerberos
  • SystemConfiguration framework di sistema macOS

Consultare la documentazione del compilatore per ulteriori informazioni.

Librerie Linux

Per Linux, le versioni della libreria sono fornite per piattaforme a 32 bit (i386) e 64 bit (x86_64).

Si noti che le librerie Linux sono state testate utilizzando GCC 4.8.0, GCC 7.2.0 e Clang 5.0 su Ubuntu.

Quando crei app desktop C++ su Linux, collega la libreria di sistema pthread al tuo progetto. Consultare la documentazione del compilatore per ulteriori informazioni. Se stai compilando con GCC 5 o successivo, definisci -D_GLIBCXX_USE_CXX11_ABI=0 .

Prossimi passi

,

Potenzia i tuoi giochi C++ con i nostri SDK Firebase C++ che forniscono un'interfaccia C++ oltre agli SDK Firebase.

Accedi a Firebase interamente dal tuo codice C++, senza dover scrivere alcun codice nativo della piattaforma. L'SDK di Firebase traduce anche molti idiomi specifici della lingua utilizzati da Firebase in un'interfaccia più familiare agli sviluppatori C++.

Scopri ulteriori informazioni su come potenziare i tuoi giochi con Firebase nella nostra pagina dei giochi Firebase .

Hai già aggiunto Firebase al tuo progetto C++? Assicurati di utilizzare la versione più recente di Firebase C++ SDK .

Prerequisiti

  • Installa quanto segue:

    • Xcode 13.3.1 o successivo
    • CocoaPods 1.10.0 o successivo
  • Assicurati che il tuo progetto abbia come target le seguenti versioni della piattaforma o successive:

    • iOS 11
    • tv OS 12
  • Configura un dispositivo fisico o usa il simulatore per eseguire la tua app.

  • Accedi a Firebase utilizzando il tuo account Google.

Passaggio 2 : crea un progetto Firebase

Prima di poter aggiungere Firebase al tuo progetto C++, devi creare un progetto Firebase per connetterti al tuo progetto C++. Visita Capire i progetti Firebase per saperne di più sui progetti Firebase.

Passaggio 3 : registra la tua app con 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 app to display the platform options.

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

  4. (Optional) Enter other app information: App nickname and App Store ID .

  5. Click Register app .

Step 4 : Add the Firebase configuration file

  1. Click Download GoogleService-Info.plist to obtain your Firebase Apple platforms config file.

  2. Open your C++ project in an IDE, then drag your config file into the root of your C++ project.

  3. If prompted, select to add the config file to all targets.

You're done with set up tasks in the Firebase console. Continue to Add Firebase C++ SDKs below.

Step 5 : Add Firebase C++ SDKs

The steps in this section are an example of how to add supported Firebase products to your Firebase C++ project.

  1. Download the Firebase C++ SDK , then unzip the SDK somewhere convenient.

    The Firebase C++ SDK is not platform-specific, but it does contain platform-specific libraries.

  2. Add Firebase pods from the unzipped SDK.

    1. Create a Podfile if you don't already have one:

      cd your-app-directory
      pod init

    2. To your Podfile, add the Firebase pods that you want to use in your app.

      Analytics enabled

      # Add the Firebase pod for Google Analytics
      pod 'FirebaseAnalytics'
      # Add the pods for any other Firebase products you want to use in your app # For example, to use Firebase Authentication and Firebase Realtime Database pod 'FirebaseAuth' pod 'FirebaseDatabase'

      Analytics not enabled

      # Add the pods for the Firebase products you want to use in your app
      # For example, to use Firebase Authentication and Firebase Realtime Database
      pod 'FirebaseAuth'
      pod 'FirebaseDatabase'
    3. Install the pods, then open the .xcworkspace file in Xcode.

      pod install
      open your-app.xcworkspace

  3. Add Firebase frameworks from the unzipped SDK.

    The easiest way to add these frameworks is usually to drag them from a Finder window directly into Xcode's Project Navigator pane (the far-left pane, by default; or click the file icon in the top-left of Xcode).

    1. Add the Firebase C++ framework firebase.framework , which is required to use any Firebase product.

    2. Add the framework for each Firebase product that you want to use. For example, to use Firebase Authentication, add firebase_auth.framework .

  4. Back in the Firebase console, in the setup workflow, click Next .

  5. If you added Analytics, run your app to send verification to Firebase that you've successfully integrated Firebase. Otherwise, you can skip this verification step.

    Your device logs will display the Firebase verification that initialization is complete. If you ran your app on an emulator that has network access, the Firebase console notifies you that your app connection is complete.

You're all set! Your C++ app is registered and configured to use Firebase products.

Available libraries

Learn more about the C++ Firebase libraries in the reference documentation and in our open-source SDK release on GitHub .

Available libraries for Apple platforms

Note that C++ libraries for Android are listed on the Android version of this setup page .

Each Firebase product has different dependencies. Be sure to add all the listed dependencies for the desired Firebase product to your Podfile and C++ project.

Each Firebase product may only support a selection of Apple OS platforms (iOS, tvOS, etc.). Check which platforms are supported by each library in Learn more about C++ and Firebase .

Firebase product Frameworks and Pods
AdMob (required) firebase.framework
firebase_admob.framework
(required) firebase_analytics.framework

pod 'FirebaseAdMob', '10.6.0'
(required) pod 'FirebaseAnalytics', '10.6.0'
Analytics (required) firebase.framework
firebase_analytics.framework

pod 'FirebaseAnalytics', '10.6.0'
Authentication (required) firebase.framework
firebase_auth.framework

pod 'FirebaseAuth', '10.6.0'
Cloud Firestore (required) firebase.framework
firebase_firestore.framework
firebase_auth.framework

pod 'FirebaseFirestore', '10.6.0'
pod 'FirebaseAuth', '10.6.0'
Cloud Functions (required) firebase.framework
firebase_functions.framework

pod 'FirebaseFunctions', '10.6.0'
Cloud Messaging (required) firebase.framework
firebase_messaging.framework
(recommended) firebase_analytics.framework

pod 'FirebaseMessaging', '10.6.0'
(recommended) pod 'FirebaseAnalytics', '10.6.0'
Cloud Storage (required) firebase.framework
firebase_storage.framework

pod 'FirebaseStorage', '10.6.0'
Dynamic Links (required) firebase.framework
firebase_dynamic_links.framework
(recommended) firebase_analytics.framework

pod 'FirebaseDynamicLinks', '10.6.0'
(recommended) pod 'FirebaseAnalytics', '10.6.0'
Realtime Database (required) firebase.framework
firebase_database.framework

pod 'FirebaseDatabase', '10.6.0'
Remote Config (required) firebase.framework
firebase_remote_config.framework
(recommended) firebase_analytics.framework

pod 'FirebaseRemoteConfig', '10.6.0'
(recommended) pod 'FirebaseAnalytics', '10.6.0'

Additional information for mobile setup

Method swizzling

On iOS, some application events (such as opening URLs and receiving notifications) require your application delegate to implement specific methods. For example, receiving a notification might require your application delegate to implement application:didReceiveRemoteNotification: . Because each iOS application has its own app delegate, Firebase uses method swizzling , which allows the replacement of one method with another, to attach its own handlers in addition to any that you might have implemented.

The Dynamic Links and Cloud Messaging libraries need to attach handlers to the application delegate using method swizzling. If you're using any of these Firebase products, at load time, Firebase will identify your AppDelegate class and swizzle the required methods onto it, chaining a call back to your existing method implementation.

Set up a desktop workflow ( beta )

When you're creating a game, it's often much easier to test your game on desktop platforms first, then deploy and test on mobile devices later in development. To support this workflow, we provide a subset of the Firebase C++ SDKs which can run on Windows, macOS, Linux, and from within the C++ editor.

  1. For desktop workflows, you need to complete the following:

    1. Configure your C++ project for CMake.
    2. Create a Firebase project
    3. Register your app (iOS or Android) with Firebase
    4. Add a mobile-platform Firebase configuration file
  2. Create a desktop version of the Firebase configuration file:

    • If you added the Android google-services.json file — When you run your app, Firebase locates this mobile file, then automatically generates a desktop Firebase config file ( google-services-desktop.json ).

    • If you added the iOS GoogleService-Info.plist file — Before you run your app, you need to convert this mobile file to a desktop Firebase config file. To convert the file, run the following command from the same directory as your GoogleService-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 in the Firebase console setup workflow. Visit Understand Firebase Projects to learn more about config files.

  3. Add Firebase SDKs to your C++ project.

    The steps below serve as an example of how to add any supported Firebase product to your C++ project. In this example, we walk through adding Firebase Authentication and Firebase Realtime Database.

    1. Set your FIREBASE_CPP_SDK_DIR environment variable to the location of the unzipped Firebase C++ SDK.

    2. To your project's CMakeLists.txt file, add the following content, including the libraries for the Firebase products that you want to use. For example, to use Firebase Authentication and Firebase 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 use Firebase Authentication and Firebase Realtime Database
      set(firebase_libs firebase_auth firebase_database firebase_app)
      target_link_libraries(${target_name} "${firebase_libs}")
      
  4. Run your C++ app.

Available libraries (desktop)

The Firebase C++ SDK includes desktop workflow support for a subset of features, enabling certain parts of Firebase to be used in standalone desktop builds on Windows, macOS, and Linux.

Firebase product Library references (using CMake)
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

The Realtime Database SDK for desktop uses REST to access your database, so you must declare the indexes that you use with Query::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 SDK libraries to your project. Consult your compiler documentation for more information.

Firebase C++ Library Windows SDK library dependencies
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 Xcode 13.3.1.

When building C++ desktop apps on macOS, link the following to your project:

  • pthread system library
  • CoreFoundation macOS system framework
  • Foundation macOS system framework
  • Security macOS system framework
  • GSS macOS system framework
  • Kerberos macOS system framework
  • SystemConfiguration 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, and Clang 5.0 on Ubuntu.

When building C++ desktop apps on Linux, link the pthread system library to your project. Consult your compiler documentation for more information. If you're building with GCC 5 or later, define -D_GLIBCXX_USE_CXX11_ABI=0 .

Prossimi passi