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 machine or an Android devicemain.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.22 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_testsUse main.cpp for quick testing:
./build/mainBuild the project with ENABLE_ASAN enabled and run it normally:
cmake -S . -B build-asan -DENABLE_ASAN=ON
cmake --build build-asan
./build-asan/unit_tests
./build-asan/mainOn macOS, ASan detects memory errors but not leaks. Instead, build the project with ENABLE_FRAME_POINTER enabled and
run it with leaks:
cmake -S . -B build-leaks -DENABLE_FRAME_POINTER=ON
cmake --build build-leaks
MallocScribble=1 leaks --atExit -- ./build-leaks/unit_tests
MallocScribble=1 leaks --atExit -- ./build-leaks/mainThe "process is not debuggable" warning is expected and doesn't affect leak detection
Use 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-persistenceBuild unit_tests with the NDK by enabling BUILD_ANDROID_TESTS, choosing the ABI (e.g. armeabi-v7a or arm64-v8a):
ABI=armeabi-v7a
cmake -S . -B android-test-$ABI \
-DCMAKE_TOOLCHAIN_FILE=~/Library/Android/sdk/ndk/28.2.13676358/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ABI \
-DANDROID_PLATFORM=android-24 \
-DBUILD_ANDROID_TESTS=ON
cmake --build android-test-$ABI --target unit_testsPush the resulting binary to a device and run it from a writable directory:
adb push android-test-$ABI/unit_tests /data/local/tmp/
adb shell "cd /data/local/tmp && ./unit_tests"The device must support the chosen ABI. Check with adb shell getprop ro.product.cpu.abilist
ctest is not available for cross-compiled builds since test discovery would need to run the binary on the host
To 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.