Firebase Telemetry Persistence Library
This library is organized to facilitate local development and cross-platform interop for Android and iOS
include/: Public headers for interop. These define the interface consumed by the SDKssrc/: Implementation of the library, including private headers and source filestests/: Unit tests designed to run on a developer's machinemain.cpp: A scratchpad for local development and experimentation
Only the core logic in include/ and src/ is compiled into the final production library. Development artifacts like
tests/ and main.cpp are used strictly for local verification and are never linked into the final binary
Use these instructions to work on the library logic itself on your host machine
- A C++17 compliant compiler
- CMake (version 3.24 or higher)
To build the library, the local scratchpad, and the unit tests:
cmake -S . -B build
cmake --build buildUnit tests use GoogleTest:
ctest --test-dir build --output-on-failureAlternatively, you can run the test executable directly:
./build/unit_testsBuild the project with ENABLE_ASAN enabled and run it normally on Linux:
cmake -S . -B build -DENABLE_ASAN=ON
cmake --build build
./build/unit_tests
./build/mainBuild the project with ENABLE_FRAME_POINTER enabled, and use leaks to run it on macOS:
cmake -S . -B build -DENABLE_FRAME_POINTER=ON
cmake --build build
leaks --atExit -- ./build/unit_tests
leaks --atExit -- ./build/mainUse main.cpp for quick testing:
./build/mainUse these instructions to build and link the library for use in an Android application
- Android NDK (Version 28.2.13676358 or similar)
To build the shared library for Android using the NDK toolchain:
cmake -S . -B android-build \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=~/Library/Android/sdk/ndk/28.2.13676358/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-24
cmake --build android-build --target firebase-telemetry-persistenceTo integrate this library in another Android project, add this to your app's build.gradle.kts:
android {
...
externalNativeBuild {
cmake {
path = file("firebase-telemetry-persistence/CMakeLists.txt")
version = "3.22.1"
}
}
}Where firebase-telemetry-persistence/CMakeLists.txt is the local path to this library
Verify building it:
swift buildVerify compatibility of C++ changes
swift testUpdate Package.swift:
let package = Package(
...
dependencies: [
// Without local changes
.package(
url: "https://github.com/firebase/firebase-telemetry-persistence.git",
branch: "main"),
// With local changes
.package(name: "firebase-telemetry-persistence", path: "../../../firebase-telemetry-persistence"),
],
targets: [
.target(
dependencies: [
...
.product(name: "FirebaseTelemetryPersistence", package: "firebase-telemetry-persistence"),
],
swiftSettings: [
.interoperabilityMode(.Cxx)
]
),
],
cxxLanguageStandard: .cxx17
)Every file containing source code (such as C++ .cpp/.h and Swift .swift files) must include copyright and license
information.
Apache header:
Copyright 2026 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.