• Stars
    star
    230
  • Rank 174,053 (Top 4 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Firebase C++ SDK

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:

Google Analytics for Firebase
Firebase Authentication Firebase Realtime Database
Firebase Dynamic Links Cloud Firestore
Cloud Functions for Firebase Firebase Invites
Firebase Cloud Messaging Firebase Remote Config
Cloud Storage for Firebase

Firebase is an app development platform with tools to help you build, grow and monetize your app. More information about Firebase can be found HERE.

  • More information about the Firebase C++ SDK can be found HERE
  • Samples on how to use the Firebase C++ SDK can be found HERE

Github Repo Size

Table of Contents

  1. Getting Started
  2. Prerequisites
  3. Building
  4. Including in Projects
  5. Contributing Guidelines
  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.

Note: Once python is installed you can use the following commands to install required packages:

  • python3 -m ensurepip --default-pip
  • python3 -m pip install --user absl-py

Prerequisites for Desktop

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

  • OpenSSL, needed for Realtime Database and Cloud Firestore

Prerequisites for Windows

Prebuilt packages for openssl can be found using google and if CMake fails to find the install path use the command line option -DOPENSSL_ROOT_DIR=[Open SSL Dir].

Prerequisites for Mac

Home brew can be used to install required dependencies:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
source $HOME/.rvm/scripts/rvm
brew install cmake python3
sudo chown -R $(whoami) /usr/local

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/tvOS

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

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
Google Analytics for Firebase firebase_analytics
Firebase Authentication firebase_auth
Firebase Realtime Database firebase_database
Firebase Dynamic Links firebase_dynamic_links
Cloud Firestore firebase_firestore
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.

By default, when building the SDK, the CMake process will download any third party dependencies that are needed for the build. This logic is in cmake/external_rules.cmake, and the accompanying cmake/external/CMakeLists.txt. If you would like to provide your own directory for these dependencies, you can override [[dependency_name]]_SOURCE_DIR and [[dependency_name]]_BINARY_DIR. If the binary directory is not provided, it defaults to the given source directory, appended with -build.

For example, to provide a custom flatbuffer directory you could run:

cmake -DFLATBUFFERS_SOURCE_DIR=/tmp/flatbuffers ..

And the binary directory would automatically be set to /tmp/flatbuffers-build.

Currently, the third party libraries that can be provided this way are:

Library
CURL
FLATBUFFERS
LIBUV
NANOPB
UWEBSOCKETS
ZLIB

Building with CMake for iOS

The Firebase C++ SDK comes with a CMake config file to build the library for iOS platforms, cmake/toolchains/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 Auth library for iOS, you could run the following commands:

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

Building with CMake for tvOS

The Firebase C++ SDK comes with a CMake config file to build the library for tvOS platforms, cmake/toolchains/apple.toolchain.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 Auth library for tvOS, you could run the following commands:

mkdir tvos_build && cd tvos_build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/apple.toolchain.cmake -DPLATFORM=TVOS ..
cmake --build . --target firebase_auth

Building XCFrameworks for both iOS and tvOS

The Firebase C++ SDK comes with a helper Python script to build XCFrameworks that work for both iOS and tvOS. This is helpful as we can use the same deliverable for both iOS and tvOS targets in the same XCode project.

# Install prereqs (like cocoapods)
./build_scripts/tvos/install_prereqs.sh
python3 scripts/gha/build_ios_tvos.py -s . -b ios_tvos_build

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
Google Analytics for Firebase :analytics:assembleRelease
Firebase Authentication :auth:assembleRelease
Firebase Realtime Database :database:assembleRelease
Firebase Dynamic Links :dynamic_links:assembleRelease
Cloud Firestore :firestore: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.

Testing

Each Firebase SDK in this repo includes a series of unit tests. These tests are built and executed by the CI system in order to validate changes and pull requests.

The provided test_windows_x32.bat, test_windows_x64.bat, test_linux.sh and test_mac_x64.sh scripts build the SDKs and execute the unit tests via ctest on Windows32, Windows64, Linux and MacOS hosts, respectively. These scripts reside in the base directory of the repository.

Known Issues

  • Mac
    • When executing tests you may be requested to unlock your Mac OS keychain. Please enter your keychain password and select Always Allow. If you still encounter repeated access request dialogs then you must unlock the keychain manually otherwise some tests will fail.
      • Open the Keychain access application on your Mac.
      • Under Keychains (upper left) select the login keychain.
      • Under Category select Passwords as a category (lower left) and find the entry not_a_real_project_id.{hashcode}. Right click it.
      • Select Get Info, select Access Control and enable the Allow all applications to access this item radio button.
      • Re-run the tests.

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.

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.

More Repositories

1

functions-samples

Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
JavaScript
12,063
star
2

flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
Dart
8,671
star
3

quickstart-android

Firebase Quickstart Samples for Android
Java
8,563
star
4

firebase-js-sdk

Firebase Javascript SDK
TypeScript
4,830
star
5

quickstart-js

Firebase Quickstart Samples for Web
HTML
4,818
star
6

FirebaseUI-Android

Optimized UI components for Firebase
Java
4,628
star
7

firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
JavaScript
4,558
star
8

firebase-tools

The Firebase Command Line Tools
TypeScript
3,994
star
9

firebase-ios-sdk

Firebase iOS SDK
Objective-C
3,583
star
10

quickstart-ios

Firebase Quickstart Samples for iOS
Swift
2,773
star
11

firebase-android-sdk

Firebase Android SDK
Java
2,244
star
12

codelab-friendlychat-web

The source for the Firebase codelab for building a cross-platform chat app
JavaScript
1,749
star
13

firebase-admin-node

Firebase Admin Node.js SDK
TypeScript
1,621
star
14

FirebaseUI-iOS

iOS UI bindings for Firebase.
Objective-C
1,507
star
15

geofire-js

GeoFire for JavaScript - Realtime location queries with Firebase
TypeScript
1,443
star
16

firebaseui-web-react

React Wrapper for firebaseUI Web
JavaScript
1,262
star
17

firebase-admin-go

Firebase Admin Go SDK
Go
1,142
star
18

superstatic

Superstatic: a static file server for fancy apps.
JavaScript
1,097
star
19

firebase-functions

Firebase SDK for Cloud Functions
TypeScript
1,024
star
20

firebase-admin-python

Firebase Admin Python SDK
Python
1,019
star
21

quickstart-nodejs

JavaScript
895
star
22

extensions

Source code for official Firebase extensions
TypeScript
892
star
23

quickstart-unity

Firebase Quickstart Samples for Unity
C#
775
star
24

snippets-android

Android snippets for firebase.google.com
Java
762
star
25

snippets-web

Web snippets for firebase.google.com
JavaScript
749
star
26

genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to develop, integrate, and test AI features with observability and evaluations. Genkit works with various models and platforms.
TypeScript
701
star
27

geofire-java

GeoFire for Java - Realtime location queries with Firebase
Java
671
star
28

firebase-admin-java

Firebase Admin Java SDK
Java
527
star
29

friendlyeats-web

JavaScript
467
star
30

geofire-objc

GeoFire for Objective-C - Realtime location queries with Firebase
Objective-C
440
star
31

snippets-node

Node.js snippets for firebase.google.com
JavaScript
369
star
32

firebase-admin-dotnet

Firebase Admin .NET SDK
C#
367
star
33

quickstart-testing

Samples demonstrating how to test your Firebase app
TypeScript
335
star
34

firebase-tools-ui

A local-first UI for Firebase Emulator Suite.
TypeScript
269
star
35

friendlyeats-android

Cloud Firestore Android codelab
Kotlin
261
star
36

codelab-friendlychat-android

Firebase FriendlyChat codelab
Kotlin
243
star
37

quickstart-java

Quickstart samples for Firebase Java Admin SDK
Java
224
star
38

firebase-functions-test

TypeScript
211
star
39

quickstart-cpp

Firebase Quickstart Samples for C++
C++
190
star
40

fastlane-plugin-firebase_app_distribution

fastlane plugin for Firebase App Distribution. https://firebase.google.com/docs/app-distribution
Ruby
166
star
41

friendlypix-ios

Friendly Pix iOS is a sample app demonstrating how to build an iOS app with the Firebase Platform.
Swift
166
star
42

quickstart-flutter

Dart
138
star
43

firebase-functions-python

Python
136
star
44

geofire-android

GeoFire for Android apps
Java
133
star
45

firebase-unity-sdk

The Firebase SDK for Unity
C#
128
star
46

friendlyeats-ios

Swift
127
star
47

snippets-ios

iOS snippets used in firebase.google.com
Objective-C
121
star
48

firebaseopensource.com

Source for firebase open source site
TypeScript
118
star
49

quickstart-python

Jupyter Notebook
115
star
50

FirebaseUI-Flutter

Dart
102
star
51

codelab-friendlychat-ios

Swift
68
star
52

snippets-rules

Snippets for security rules on firebase.google.com
TypeScript
45
star
53

emulators-codelab

JavaScript
44
star
54

oss-bot

Robot friend for open source repositories
TypeScript
36
star
55

firebase-bower

Firebase Web Client
JavaScript
35
star
56

snippets-flutter

Dart
30
star
57

snippets-go

Golang snippets for firebase docs
Go
24
star
58

snippets-java

Java snippets for firebase.google.com
Java
17
star
59

firebase-docs

TypeScript
16
star
60

abseil-cpp-SwiftPM

C++
13
star
61

firebase-testlab-instr-lib

Java
13
star
62

snippets-cpp

C++ snippets for firebase.google.com
C++
12
star
63

SpecsStaging

SpecsStaging
11
star
64

SpecsTesting

Ruby
11
star
65

rtdb-to-csv

JavaScript
11
star
66

appquality-codelab-ios

Firebase iOS App Quality Codelab
Objective-C
11
star
67

level-up-with-firebase

C#
9
star
68

boringSSL-SwiftPM

C++
8
star
69

firestore-bundle-builder

TypeScript
7
star
70

.github

Default configuration for Firebase repos
6
star
71

nginx

This repo is a PUBLIC FORK
C
6
star
72

SpecsDev

6
star
73

snippets-python

Python snippets for firebase.google.com
4
star
74

firebase-release-dashboard

JavaScript
4
star
75

ok

HTTPS CDN Proxy Healthy Check
4
star
76

grpc-SwiftPM

C++
3
star
77

crashlytics-testapps

Java
2
star
78

data-connect-ios-sdk

Swift
2
star
79

.allstar

1
star