firebase_ffi 0.1.1
firebase_ffi: ^0.1.1 copied to clipboard
Firebase for Dart and Flutter on desktop Linux through a single FFI code asset — no platform channel, no embedder plugin. Products are opt-in per app.
Changelog #
0.1.1 #
Fixed #
GoogleServicesConfig.parseno longer requiresfirebase_url. The console writes that key only once a Realtime Database exists, so a project using Auth or Firestore alone could not read its own config.databaseUrlisString?, like the bucket beside it, andinitDatabasetakes it as optional.- Windows: linking Remote Config failed on two ICU symbols.
app/src/locale.ccincludes<icu.h>there, andGetTimezoneis reached only from Remote Config, so no earlier Windows build had pulled the object in.icujoins the system libraries the SDK publishes through its package config. - Windows: the first Realtime Database write faulted.
Repo's constructor abandoned setup when it could not create a directory named after the database url — against the emulator that name holds:and?, both reserved in NTFS paths — and returned beforeserver_sync_tree_was built, leaving a null member behind a Database the SDK still handed out. The cache directory is now worked out only when persistence is enabled, which is off here. - An app initialized with no database url is refused by the Database rather than accepting writes it can never deliver.
Added #
hooks.user_defines.firebase_ffi.debug_infoemits debug info beside the optimized build: a PDB under MSVC,-gelsewhere. Off by default.platforms:names linux, macos and windows. pub.flutter-io.cn inferred android and ios from the imports; neither can work, and on mobile the official FlutterFire plugins are the implementation.
Notes #
- The binding suite runs against the emulator suite on all three desktops now, not only Linux. Both Windows bugs above were found that way, within an hour of each other.
0.1.0 #
First release. Prototype: the API is small and expected to change.
Added #
- Realtime Database through a single FFI code asset — no platform channel, no
embedder plugin.
initDatabase,setString, andonValueas aStream<DbSnapshot>. - Snapshots delivered with
Dart_PostCObject_DLaskExternalTypedData, so the SDK's buffer is read in place.firebase::Variantis serialized to a tagged flat encoding and decoded in Dart. - Authentication on the same
firebase::Appas the database:signInAnonymously,signInWithCustomToken,signOut,currentUid, andrestoredUidfor a session restored from the platform secure store. Failures throwAuthExceptioncarrying the SDK's own error code and message. GoogleServicesConfig— reads the console'sgoogle-services.json, which is what desktop Linux is configured from since it has no config file of its own.tool/mint_custom_token.dart— signs a Firebase custom token for a device uid from a service-account key, usingopensslso it needs no dependencies.- Build hook driving CMake, configured through
hooks.user_defines:firebase_sdkfor the SDK prefix (relative to the declaringpubspec.yaml) andwith_firebase: falsefor a transport-only build. - Benchmarks for the FFI call and snapshot paths, comparing
kExternalTypedDataagainst a copying post:bin/bench.dartandrunBenchmarks().
Fixed #
- The build hook reconfigures when a previous CMake configure failed partway.
CMake writes
CMakeCache.txtbefore it can fail, and treating that as "already configured" made every later run die asninja: build.ninja: No such file or directory, long after the real error.
Changed #
-
The snapshot wire format is CBOR (RFC 8949) rather than a private tagged encoding: TinyCBOR on the native side, the
cborpackage on the Dart side. Byte strings now survive as bytes; the previous encoding had no way to represent them and wrote null. -
The build hook resolves the built library by target OS (
.so/.dylib/.dll, including a multi-config generator'sRelease/subdirectory) and resolves tools on PATH directly rather than shelling out towhich, which does not exist on Windows. -
Linking the Firebase C++ SDK is implemented per platform —
--start-groupfor GNU ld's archive cycles on Linux, the frameworks ld64 needs on macOS, and the matching MSVC runtime on Windows. A fourth platform is refused at configure time with what a port needs, rather than failing inside the linker. A transport-only build has no such dependencies.
Notes #
- A missing SDK fails at configure time with instructions, rather than producing a library that fails at runtime.
- The build hook derives the C++ driver from the configured C compiler, and
falls back to
g++when the toolchain's clang cannot compile C++20 against the system libstdc++ — Flutter's Linux desktop build pins clang 18, which cannot parse a GCC 16 libstdc++. - Linux is what runs against a backend: x86-64 in CI against the emulator suite, aarch64 (Raspberry Pi 5) by hand against a live project. macOS and Windows build and link in CI on every change — Windows requires MSVC, since the SDK's archives cannot be linked by MinGW — but nothing exercises them against a backend yet.