使用我們的 Firebase C++ SDK 增強您的 C++ 遊戲,它在 Firebase SDK 之上提供了一個 C++ 接口。
完全從您的 C++ 代碼訪問 Firebase,無需編寫任何平台原生代碼。 Firebase SDK 還將 Firebase 使用的許多特定語言的習語翻譯成 C++ 開發人員更熟悉的界面。
在我們的Firebase 遊戲頁面上找到有關使用 Firebase 為您的遊戲提供動力的更多信息。
已經將 Firebase 添加到您的 C++ 項目?確保您使用的是最新版本的Firebase C++ SDK 。
先決條件
安裝以下內容:
- Xcode 13.3.1 或更高版本
- CocoaPods 1.10.0 或更高版本
確保您的項目面向以下平台版本或更高版本:
- iOS 11
- 電視操作系統 12
設置物理設備或使用模擬器來運行您的應用程序。
對於 Apple 平台上的雲消息傳遞,先決條件如下:
- 設置物理 Apple 設備。
- 為您的Apple Developer 帳戶獲取 Apple Push Notification Authentication Key。
- 在App > Capabilities下的 Xcode 中啟用推送通知。
使用您的 Google 帳戶登錄 Firebase 。
第 2 步:創建一個 Firebase 項目
在將 Firebase 添加到 C++ 項目之前,您需要創建一個 Firebase 項目以連接到 C++ 項目。訪問了解 Firebase 項目以了解有關 Firebase 項目的更多信息。
第 3 步:向 Firebase 註冊您的應用
要在您的 Apple 應用程序中使用 Firebase,您需要在 Firebase 項目中註冊您的應用程序。註冊您的應用程序通常稱為將您的應用程序“添加”到您的項目中。
轉到Firebase 控制台。
在項目概覽頁面的中央,單擊iOS+圖標以啟動設置工作流程。
如果您已將應用程序添加到 Firebase 項目,請單擊添加應用程序以顯示平台選項。
在bundle ID字段中輸入您應用程序的 bundle ID。
捆綁包 ID唯一標識 Apple 生態系統中的應用程序。
查找您的包 ID:在 Xcode 中打開您的項目,在項目導航器中選擇頂級應用程序,然後選擇常規選項卡。
Bundle Identifier字段的值是包 ID(例如,
com.yourcompany.yourproject
)。請注意,bundle ID 值區分大小寫,在您的 Firebase 項目中註冊後,無法更改此 Firebase 應用程序的值。
(可選)輸入其他應用信息:應用暱稱和App Store ID 。
應用暱稱:僅在 Firebase 控制台中對您可見的內部便利標識符
App Store ID :由 Firebase 動態鏈接用於將用戶重定向到您的 App Store 頁面,由 Google Analytics 用於將轉換事件導入 Google Ads 。如果您的應用還沒有 App Store ID,您可以稍後在項目設置中添加 ID。
單擊註冊應用程序。
第 4 步:添加 Firebase 配置文件
單擊下載 GoogleService-Info.plist以獲取您的 Firebase Apple 平台配置文件。
Firebase 配置文件包含項目的唯一但非機密標識符。要了解有關此配置文件的更多信息,請訪問了解 Firebase 項目。
您可以隨時再次下載您的Firebase 配置文件。
確保配置文件名未附加其他字符,例如
(2)
。
在 IDE 中打開 C++ 項目,然後將配置文件拖到 C++ 項目的根目錄中。
如果出現提示,請選擇將配置文件添加到所有目標。
您已完成 Firebase 控制台中的設置任務。繼續在下方添加 Firebase C++ SDK 。
第 5 步:添加 Firebase C++ SDK
本節中的步驟是如何將受支持的 Firebase 產品添加到您的 Firebase C++ 項目的示例。
下載Firebase C++ SDK ,然後將 SDK 解壓縮到方便的位置。
Firebase C++ SDK 不是特定於平台的,但它確實包含特定於平台的庫。
從解壓縮的 SDK 添加 Firebase pod 。
如果您還沒有 Podfile,請創建一個:
cd your-app-directory
pod init
在您的 Podfile 中,添加您要在您的應用中使用的 Firebase pod。
啟用分析
# 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'未啟用分析
# 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'
安裝 pod,然後在 Xcode 中打開
.xcworkspace
文件。pod install
open your-app.xcworkspace
從解壓縮的 SDK 添加 Firebase框架。
添加這些框架的最簡單方法通常是將它們從
Finder
窗口直接拖到 Xcode 的Project Navigator窗格(默認情況下是最左側的窗格;或單擊 Xcode 左上角的文件圖標)。添加 Firebase C++ 框架
firebase.framework
,這是使用任何 Firebase 產品所必需的。為您要使用的每個 Firebase 產品添加框架。例如,要使用 Firebase 身份驗證,請添加
firebase_auth.framework
。
返回 Firebase 控制台,在設置工作流程中,單擊下一步。
如果您添加了 Analytics,請運行您的應用以向 Firebase 發送您已成功集成 Firebase 的驗證。否則,您可以跳過此驗證步驟。
您的設備日誌將顯示初始化已完成的 Firebase 驗證。如果您在具有網絡訪問權限的模擬器上運行您的應用程序, Firebase 控制台會通知您應用程序連接已完成。
一切就緒!您的 C++ 應用已註冊並配置為使用 Firebase 產品。
可用庫
在參考文檔和我們在GitHub上發布的開源 SDK 中了解有關 C++ Firebase 庫的更多信息。
適用於 Apple 平台的可用庫
請注意,適用於 Android 的 C++ 庫已列在此設置頁面的 Android 版本中。
每個 Firebase 產品都有不同的依賴項。請務必將所需 Firebase 產品的所有列出的依賴項添加到您的 Podfile 和 C++ 項目中。
每個 Firebase 產品可能僅支持部分 Apple 操作系統平台(iOS、tvOS 等)。在了解有關 C++ 和 Firebase 的更多信息中檢查每個庫支持哪些平台。
火力地堡產品 | 框架和 Pod |
---|---|
AdMob | (必需) firebase.framework firebase_admob.framework (必需) firebase_analytics.framework pod 'FirebaseAdMob', '10.6.0' (必填) pod 'FirebaseAnalytics', '10.6.0' |
分析 | (必需) firebase.framework firebase_analytics.framework pod 'FirebaseAnalytics', '10.6.0' |
驗證 | (必需) firebase.framework firebase_auth.framework pod 'FirebaseAuth', '10.6.0' |
雲端 Firestore | (必需) firebase.framework firebase_firestore.framework firebase_auth.framework pod 'FirebaseFirestore', '10.6.0' pod 'FirebaseAuth', '10.6.0' |
雲端功能 | (必需) firebase.framework firebase_functions.framework pod 'FirebaseFunctions', '10.6.0' |
雲消息 | (必需) firebase.framework firebase_messaging.framework (推薦) firebase_analytics.framework pod 'FirebaseMessaging', '10.6.0' (推薦) pod 'FirebaseAnalytics', '10.6.0' |
雲儲存 | (必需) firebase.framework firebase_storage.framework pod 'FirebaseStorage', '10.6.0' |
動態鏈接 | (必需) firebase.framework firebase_dynamic_links.framework (推薦) firebase_analytics.framework pod 'FirebaseDynamicLinks', '10.6.0' (推薦) pod 'FirebaseAnalytics', '10.6.0' |
實時數據庫 | (必需) firebase.framework firebase_database.framework pod 'FirebaseDatabase', '10.6.0' |
遠程配置 | (必需) firebase.framework firebase_remote_config.framework (推薦) firebase_analytics.framework pod 'FirebaseRemoteConfig', '10.6.0' (推薦) pod 'FirebaseAnalytics', '10.6.0' |
移動設置的附加信息
方法調配
在 iOS 上,某些應用程序事件(例如打開 URL 和接收通知)需要您的應用程序委託來實現特定的方法。例如,接收通知可能需要您的應用程序委託來實現application:didReceiveRemoteNotification:
。因為每個 iOS 應用程序都有自己的應用程序委託,所以 Firebase 使用method swizzling允許將一種方法替換為另一種方法,以在您可能已經實現的任何處理程序之外附加自己的處理程序。
動態鏈接和雲消息傳遞庫需要使用方法調配將處理程序附加到應用程序委託。如果您正在使用這些 Firebase 產品中的任何一個,在加載時,Firebase 將識別您的AppDelegate
類並將所需的方法混入其中,將回調鏈接回您現有的方法實現。
設置桌面工作流程(測試版)
當您創建遊戲時,通常更容易先在桌面平台上測試您的遊戲,然後在稍後的開發過程中在移動設備上進行部署和測試。為支持此工作流程,我們提供了Firebase C++ SDK 的一個子集,它們可以在 Windows、macOS、Linux 上以及從 C++ 編輯器中運行。
對於桌面工作流,您需要完成以下操作:
- 為 CMake 配置 C++ 項目。
- 創建一個 Firebase 項目
- 向 Firebase 註冊您的應用(iOS 或 Android)
- 添加移動平台 Firebase 配置文件
創建 Firebase 配置文件的桌面版本:
如果您添加了 Android
google-services.json
文件——當您運行您的應用程序時,Firebase 會找到此移動文件,然後自動生成桌面Firebase 配置文件 (google-services-desktop.json
)。如果您添加了 iOS
GoogleService-Info.plist
文件——在運行您的應用程序之前,您需要將此移動文件轉換為桌面Firebase 配置文件。要轉換文件,請從與GoogleService-Info.plist
文件相同的目錄運行以下命令:generate_xml_from_google_services_json.py --plist -i GoogleService-Info.plist
此桌面配置文件包含您在 Firebase 控制台設置工作流程中輸入的 C++ 項目 ID。訪問了解 Firebase 項目以了解有關配置文件的更多信息。
將 Firebase SDK 添加到您的 C++ 項目。
以下步驟作為示例說明如何將任何受支持的 Firebase 產品添加到您的 C++ 項目。在此示例中,我們將介紹如何添加 Firebase 身份驗證和 Firebase 實時數據庫。
將
FIREBASE_CPP_SDK_DIR
環境變量設置為解壓縮的 Firebase C++ SDK 的位置。在您項目的
CMakeLists.txt
文件中,添加以下內容,包括您要使用的 Firebase 產品的庫。例如,要使用 Firebase 身份驗證和 Firebase 實時數據庫:# 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}")
運行您的 C++ 應用程序。
可用庫(桌面)
Firebase C++ SDK 包括對部分功能的桌面工作流支持,使 Firebase 的某些部分能夠在 Windows、macOS 和 Linux 上的獨立桌面構建中使用。
火力地堡產品 | 庫引用(使用 CMake) |
---|---|
驗證 | firebase_auth (必需) firebase_app |
雲端 Firestore | firebase_firestore firebase_auth firebase_app |
雲端功能 | firebase_functions (必需) firebase_app |
雲儲存 | firebase_storage (必需) firebase_app |
實時數據庫 | firebase_database (必需) firebase_app |
遠程配置 | firebase_remote_config (必需) firebase_app |
Firebase 將剩餘的桌面庫作為存根(非功能性)實現提供,以便在為 Windows、macOS 和 Linux 構建時提供便利。因此,您不需要有條件地編譯代碼以針對桌面。
實時數據庫桌面
桌面版實時數據庫 SDK 使用 REST 訪問您的數據庫,因此您必須聲明您在桌面上使用Query::OrderByChild()
的索引,否則您的偵聽器將失敗。
桌面設置的附加信息
Windows 庫
對於 Windows,庫版本是根據以下內容提供的:
- 構建平台:32 位 (x86) 與 64 位 (x64) 模式
- Windows運行環境:多線程/MT vs 多線程DLL/MD
- 目標:發布與調試
請注意,以下庫已使用 Visual Studio 2015 和 2017 進行測試。
在 Windows 上構建 C++ 桌面應用程序時,將以下 Windows SDK 庫鏈接到您的項目。有關更多信息,請參閱您的編譯器文檔。
Firebase C++ 庫 | Windows SDK 庫依賴項 |
---|---|
驗證 | advapi32, ws2_32, crypt32 |
雲端 Firestore | advapi32, ws2_32, crypt32, rpcrt4, ole32, shell32 |
雲端功能 | advapi32, ws2_32, crypt32, rpcrt4, ole32 |
雲儲存 | advapi32, ws2_32, crypt32 |
實時數據庫 | advapi32, ws2_32, crypt32, iphlpapi, psapi, userenv |
遠程配置 | advapi32, ws2_32, crypt32, rpcrt4, ole32 |
macOS 庫
對於 macOS (Darwin),為 64 位 (x86_64) 平台提供了庫版本。為方便起見,還提供了框架。
請注意,macOS 庫已經使用 Xcode 13.3.1 進行了測試。
在 macOS 上構建 C++ 桌面應用程序時,將以下內容鏈接到您的項目:
-
pthread
系統庫 CoreFoundation
macOS 系統框架Foundation
macOS系統框架Security
macOS 系統框架GSS
macOS 系統框架Kerberos
macOS 系統框架SystemConfiguration
macOS系統框架
有關更多信息,請參閱您的編譯器文檔。
Linux 庫
對於 Linux,為 32 位 (i386) 和 64 位 (x86_64) 平台提供了庫版本。
請注意,Linux 庫是在 Ubuntu 上使用 GCC 4.8.0、GCC 7.2.0 和 Clang 5.0 進行測試的。
在 Linux 上構建 C++ 桌面應用程序時,將pthread
系統庫鏈接到您的項目。有關更多信息,請參閱您的編譯器文檔。如果您使用 GCC 5 或更高版本構建,請定義-D_GLIBCXX_USE_CXX11_ABI=0
。
下一步
探索GitHub 中的開源 SDK 。
準備啟動您的應用程序:
- 在 Google Cloud Console 中為您的項目設置預算提醒。
- 監控 Firebase 控制台中的使用情況和計費儀表板,以全面了解項目在多個 Firebase 服務中的使用情況。
- 查看Firebase 啟動清單。
使用我們的 Firebase C++ SDK 增強您的 C++ 遊戲,它在 Firebase SDK 之上提供了一個 C++ 接口。
完全從您的 C++ 代碼訪問 Firebase,無需編寫任何平台原生代碼。 Firebase SDK 還將 Firebase 使用的許多特定語言的習語翻譯成 C++ 開發人員更熟悉的界面。
在我們的Firebase 遊戲頁面上找到有關使用 Firebase 為您的遊戲提供動力的更多信息。
已經將 Firebase 添加到您的 C++ 項目?確保您使用的是最新版本的Firebase C++ SDK 。
先決條件
安裝以下內容:
- Xcode 13.3.1 或更高版本
- CocoaPods 1.10.0 或更高版本
確保您的項目面向以下平台版本或更高版本:
- iOS 11
- 電視操作系統 12
設置物理設備或使用模擬器來運行您的應用程序。
對於 Apple 平台上的雲消息傳遞,先決條件如下:
- 設置物理 Apple 設備。
- 為您的Apple Developer 帳戶獲取 Apple Push Notification Authentication Key。
- 在App > Capabilities下的 Xcode 中啟用推送通知。
使用您的 Google 帳戶登錄 Firebase 。
第 2 步:創建一個 Firebase 項目
在將 Firebase 添加到 C++ 項目之前,您需要創建一個 Firebase 項目以連接到 C++ 項目。訪問了解 Firebase 項目以了解有關 Firebase 項目的更多信息。
Step 3 : 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.
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 bundle ID field.
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 General tab.
The value of the Bundle Identifier field 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 nickname and App Store ID .
App nickname : An internal, convenience identifier that is only visible to you in the Firebase console
App Store ID : Used by Firebase Dynamic Links to redirect users to your App Store page and by Google Analytics to import conversion events into Google Ads . If your app doesn't yet have an App Store ID, you can add the ID later in your Project settings .
Click Register app .
Step 4 : Add the Firebase configuration file
Click Download GoogleService-Info.plist to obtain your Firebase Apple platforms config file.
The Firebase config file contains unique, but non-secret identifiers for your project. 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)
.
Open your C++ project in an IDE, then drag your config file into the root of your C++ project.
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.
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.
Add Firebase pods from the unzipped SDK.
Create a Podfile if you don't already have one:
cd your-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 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'
Install the pods, then open the
.xcworkspace
file in Xcode.pod install
open your-app.xcworkspace
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).Add the Firebase C++ framework
firebase.framework
, which is required to use any Firebase product.Add the framework for each Firebase product that you want to use. For example, to use Firebase Authentication, add
firebase_auth.framework
.
Back in the Firebase console, in the setup workflow, click Next .
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.
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 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 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 in the Firebase console setup workflow. Visit Understand Firebase Projects to learn more about config files.
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.
Set your
FIREBASE_CPP_SDK_DIR
environment variable to the location of the unzipped Firebase C++ SDK.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}")
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
.
Next steps
Explore sample Firebase apps .
Explore the open source SDK in GitHub .
Prepare to launch your app:
- Set up budget alerts for your project in the Google Cloud Console.
- Monitor the Usage and billing dashboard in the Firebase console to get an overall picture of your project's usage across multiple Firebase services.
- Review the Firebase launch checklist .