Skip to content
Firebase C++ SDK
Branch: master
Clone or download
a-maurice Update CMake files with FIRInstanceId's new layout
Instance ID changed their layout to be inline with the other iOS SDKs, so update the CMake scripts to use that layout instead.

PiperOrigin-RevId: 244440380
Latest commit 6a0476b Apr 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Android Updating the dependencies in AdMob to work around a bug, and mentione… Apr 19, 2019
admob Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
analytics Create C++ and Unity testapp file groups for the testapp builders. Apr 19, 2019
android_build_files Initial open source commit. Mar 16, 2019
app Update CMake files with FIRInstanceId's new layout Apr 19, 2019
auth Automated g4 rollback of changelist 243900946. Apr 19, 2019
cmake Initial open source commit. Mar 16, 2019
database [SafeReference] Move safe_reference from database to app so other pac… Apr 19, 2019
dynamic_links
functions Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
gradle/wrapper Initial open source commit. Mar 16, 2019
instance_id Update CMake files with FIRInstanceId's new layout Apr 19, 2019
invites
messaging Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
release_build_files Updating the dependencies in AdMob to work around a bug, and mentione… Apr 19, 2019
remote_config Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
storage Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
CMakeLists.txt
CONTRIBUTING.md Initial open source commit. Mar 16, 2019
LICENSE Initial open source commit. Mar 16, 2019
README.md Initial open source commit. Mar 16, 2019
binary_to_array.py
build.gradle
build_type_header.py Initial open source commit. Mar 16, 2019
cpp_sdk_version.json Update the C++ and Unity versions to 5.7.0, including release notes Apr 19, 2019
generate_xml_from_google_services_json.exe
generate_xml_from_google_services_json.py Initial open source commit. Mar 16, 2019
gradlew
gradlew.bat Initial open source commit. Mar 16, 2019
readme_for_generate_xml_from_google_services_json_exe.txt Initial open source commit. Mar 16, 2019
settings.gradle
version.sh Update Firebase C++/Unity to use Firebase iOS 5.20.2. Apr 19, 2019
version_header.py Initial open source commit. Mar 16, 2019

README.md

Firebase C++ Open Source Development

The repository contains the Firebase C++ SDK source, with support for Android, iOS, and desktop platforms. It includes the following Firebase libraries:

Firebase is an app development platform with tools to help you build, grow and monetize your app. More information about Firebase can be found at https://firebase.google.com.

More information about the Firebase C++ SDK can be found at https://firebase.google.com/docs/cpp/setup. Samples on how to use the Firebase C++ SDK can be found at https://github.com/firebase/quickstart-cpp.

Table of Contents

  1. Getting Started
  2. Prerequisites
    1. Prerequisites for Desktop
    2. Prerequisites for Android
    3. Prerequisites for iOS
  3. Building
    1. Building with CMake
      1. Building with CMake for iOS
    2. Building with Gradle for Android
      1. Proguard File Generation
  4. Including in Projects
    1. Including in CMake Projects
    2. Including in Android Gradle Projects
  5. Contributing
  6. License

Getting Started

You can clone the repo with the following command:

git clone https://github.com/firebase/firebase-cpp-sdk.git

Prerequisites

The following prerequisites are required for all platforms. Be sure to add any directories to your PATH as needed.

Prerequisites for Desktop

The following prerequisites are required when building the libraries for desktop platforms.

Prerequisites for Android

The following prerequisites are required when building the libraries for Android.

  • Android SDK, Android NDK, and CMake for Android (version 3.10.2 recommended)
    • Download sdkmanager (either independently, or as a part of Android Studio) here
    • Follow these instructions to install the necessary build tools
  • (Windows only) Strings (from Microsoft Sysinternals)

    Important - Strings EULA
    You will have to run Strings once from the command line to accept the EULA before it will work as part of the build process.

Note that we include the Gradle wrapper, which if used will acquire the necessary version of Gradle for you.

Prerequisites for iOS

The following prerequisites are required when building the libraries for iOS.

Building

Building with CMake

The build uses CMake to generate the necessary build files, and supports out of source builds. The CMake following targets are available to build and link with:

Feature CMake Target
App (base library) firebase_app
AdMob firebase_admob
Google Analytics for Firebase firebase_analytics
Firebase Authentication firebase_auth
Firebase Realtime Database firebase_database
Firebase Dynamic Links firebase_dynamic_links
Cloud Functions for Firebase firebase_functions
Firebase Invites firebase_invites
Firebase Cloud Messaging firebase_messaging
Firebase Remote Config firebase_remote_config
Cloud Storage for Firebase firebase_storage

For example, to build the Analytics library, you could run the following commands:

mkdir desktop_build && cd desktop_build
cmake ..
cmake --build . --target firebase_analytics

Note that you can provide a different generator on the configure step, for example to generate a project for Visual Studio 2017, you could run:

cmake -G “Visual Studio 15 2017” ..

More information on generators can be found at https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html.

Building with CMake for iOS

The Firebase C++ SDK comes with a CMake config file to build the library for iOS platforms, cmake/ios.cmake. In order to build with it, when running the CMake configuration pass it in with the CMAKE_TOOLCHAIN_FILE definition. For example, to build the Analytics library for iOS, you could run the following commands:

mkdir ios_build && cd ios_build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.cmake ..
cmake --build . --target firebase_analytics

Building with Gradle for Android

When building the Firebase C++ SDK for Android, gradle is used in combination with CMake when producing the libraries. Each Firebase feature is its own gradle subproject off of the root directory. The gradle target to build the release version of each Firebase library is:

Feature Gradle Target
App (base library) :app:assembleRelease
AdMob :admob:assembleRelease
Google Analytics for Firebase :analytics:assembleRelease
Firebase Authentication :auth:assembleRelease
Firebase Realtime Database :database:assembleRelease
Firebase Dynamic Links :dynamic_links:assembleRelease
Cloud Functions for Firebase :functions:assembleRelease
Firebase Invites :invites:assembleRelease
Firebase Cloud Messaging :messaging:assembleRelease
Firebase Remote Config :remote_config:assembleRelease
Cloud Storage for Firebase :storage:assembleRelease

For example, to build the release version of the Analytics library, you could run the following from the root directory:

./gradlew :analytics:assembleRelease

Proguard File Generation

Note that as part of the build process, each library generates a proguard file that should be included in your application. The generated file is located in each library’s build directory. For example, the Analytics proguard file would be generated to analytics/build/analytics.pro.

Including in Projects

Including in CMake Projects

Including the Firebase C++ SDK to another CMake project is fairly straightforward. In the CMakeLists.txt file that wants to include the Firebase C++ SDK, you can use add_subdirectory, providing the location of the cloned repository. For example, to add Analytics, you could add the following to your CMakeLists.txt file:

add_subdirectory( [[Path to the Firebase C++ SDK]] )
target_link_libraries( [[Your CMake Target]] firebase_analytics firebase_app)

Additional examples of how to do this for each library are available in the C++ Quickstarts.

Including in Android Gradle Projects

In order to link the Firebase C++ SDK with your gradle project, in addition to the CMake instructions above, you can use Android/firebase_dependencies.gradle to link the libraries, their dependencies, and the generated proguard files. For example, to add Analytics, you could add the following to your build.gradle file:

apply from: “[[Path to the Firebase C++ SDK]]/Android/firebase_dependencies.gradle”
firebaseCpp.dependencies {
  analytics
}

Additional examples of how to do this for each library are available in the C++ Quickstarts.

Contributing

We love contributions, but note that we are still working on setting up our test infrastructure, so we may choose not to accept pull requests until we have a way to validate those changes on GitHub. Please read our contribution guidelines to get started.

License

The contents of this repository is licensed under the Apache License, version 2.0.

Your use of Firebase is governed by the Terms of Service for Firebase Services.

You can’t perform that action at this time.