feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config) - #158
Draft
therajanmaurya wants to merge 3 commits into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…e.kts cmp-firebase/src/androidMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/FirebaseInitProvider.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a single commonMain entry point —
FirebaseKit.initialize(config)— that initializes Firebase programmatically from one per-platformFirebaseConfig, with nogoogle-services.json/GoogleService-Info.plist/ Swiftconfigure()line required. GitLive-native init runs on android/ios/macos/tvos/js; a Measurement-Protocol tier covers jvm/watchos/linux/mingw/wasmjs. The legacy no-arginitialize()is retained, so the change is fully additive (zero breaking change).Changes
commonMain init surface
FirebaseOptions.kt— common superset options data class (applicationId/apiKeyrequired; others optional, per-platform-required fields documented in KDoc).FirebaseConfig.kt— per-platform options (android/apple(ios+macos+tvos) /web) +measurementProtocol: MpConfig?, aBuilder, and a pureoptionsForPlatform(platform)/optionsForCurrentPlatform()selector seam.FirebaseRuntime.kt— internal@Volatileholder for the active config.PlatformInit.kt—internal expect fun platformInitializeFirebase(options).FirebaseKit.kt— newinitialize(config)overload (idempotent, never throws on missing options → NoOp + WARN); no-arginitialize()kept.Per-platform actuals + Android context
firebaseMain/PlatformInit.firebase.kt— native actual:FirebaseOptions.toGitLive()→Firebase.initialize(...)via the newdev.gitlive:firebase-appdependency.nonFirebaseMain/PlatformInit.nonfirebase.kt— MP-tier no-op actual.androidMain/AndroidFirebaseContext.kt+FirebaseInitProvider.kt— capturesapplicationContext(no longer auto-inits).Transport routing + JVM re-tier
nonFirebaseMain/analytics/AnalyticsProvider.nonfirebase.kt— auto-wiresMeasurementProtocolAnalyticsHelperfromFirebaseRuntime.config.measurementProtocol(was a hard NoOp).analytics/InMemorySettings.kt— portable Settings for the MP client-id.build.gradle.kts—firebase-apponfirebaseMain;jvmMainre-tieredfirebaseMain → nonFirebaseMain(GitLive's JVM analytics is a stub);gradle/libs.versions.tomladds the coordinate.Tests, canary, sample, docs, API
jvmTest/FirebaseConfigTest.kt(selection / idempotency / missing-keys no-throw) +AnalyticsTierRoutingTest.kt(MP-when-present / NoOp-when-absent).tests/fixtures/firebase-commonmain-init-canary/{red,green}/ + run.sh(RED hard-NoOp vs GREEN config-reading).FirebaseAnalyticsDemoScreen.ktdemonstrates the one-call path;README.mddocuments per-platform keys.api/jvm/cmp-firebase.api— BCV baseline regenerated for the new public surface.Verification (all green, 2026-08-23)
:cmp-firebase:build(all 20 targets) → BUILD SUCCESSFUL;allTestsincl. ios/tvos/macos simulator + jvm tests green.:cmp-firebase:apiDump+:cmp-firebase:apiCheck→ green (baseline carriesFirebaseConfig+initialize(FirebaseConfig)).run.sh→canary OK.Notable files
cmp-firebase/src/commonMain/.../firebase/FirebaseKit.kt— the newinitialize(config)entry point.cmp-firebase/src/firebaseMain/.../firebase/PlatformInit.firebase.kt— GitLive programmatic init.cmp-firebase/build.gradle.kts— the JVM re-tier onto the MP fallback.