Skip to content

feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config) - #158

Draft
therajanmaurya wants to merge 3 commits into
MobileByteLabs:devfrom
therajanmaurya:session-kmp-toolkit-20260821162600499
Draft

feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config)#158
therajanmaurya wants to merge 3 commits into
MobileByteLabs:devfrom
therajanmaurya:session-kmp-toolkit-20260821162600499

Conversation

@therajanmaurya

@therajanmaurya therajanmaurya commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a single commonMain entry point — FirebaseKit.initialize(config) — that initializes Firebase programmatically from one per-platform FirebaseConfig, with no google-services.json / GoogleService-Info.plist / Swift configure() 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-arg initialize() is retained, so the change is fully additive (zero breaking change).

Changes

commonMain init surface

  • FirebaseOptions.kt — common superset options data class (applicationId/apiKey required; others optional, per-platform-required fields documented in KDoc).
  • FirebaseConfig.kt — per-platform options (android / apple (ios+macos+tvos) / web) + measurementProtocol: MpConfig?, a Builder, and a pure optionsForPlatform(platform) / optionsForCurrentPlatform() selector seam.
  • FirebaseRuntime.kt — internal @Volatile holder for the active config.
  • PlatformInit.ktinternal expect fun platformInitializeFirebase(options).
  • FirebaseKit.kt — new initialize(config) overload (idempotent, never throws on missing options → NoOp + WARN); no-arg initialize() kept.

Per-platform actuals + Android context

  • firebaseMain/PlatformInit.firebase.kt — native actual: FirebaseOptions.toGitLive()Firebase.initialize(...) via the new dev.gitlive:firebase-app dependency.
  • nonFirebaseMain/PlatformInit.nonfirebase.kt — MP-tier no-op actual.
  • androidMain/AndroidFirebaseContext.kt + FirebaseInitProvider.kt — captures applicationContext (no longer auto-inits).

Transport routing + JVM re-tier

  • nonFirebaseMain/analytics/AnalyticsProvider.nonfirebase.kt — auto-wires MeasurementProtocolAnalyticsHelper from FirebaseRuntime.config.measurementProtocol (was a hard NoOp).
  • analytics/InMemorySettings.kt — portable Settings for the MP client-id.
  • build.gradle.ktsfirebase-app on firebaseMain; jvmMain re-tiered firebaseMain → nonFirebaseMain (GitLive's JVM analytics is a stub); gradle/libs.versions.toml adds 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.kt demonstrates the one-call path; README.md documents 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; allTests incl. ios/tvos/macos simulator + jvm tests green.
  • :cmp-firebase:apiDump + :cmp-firebase:apiCheck → green (baseline carries FirebaseConfig + initialize(FirebaseConfig)).
  • canary run.shcanary OK.

Notable files

  • cmp-firebase/src/commonMain/.../firebase/FirebaseKit.kt — the new initialize(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.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6daae44e-01ab-434c-b7dc-2661115c26b9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…e.kts cmp-firebase/src/androidMain/kotlin/io/github/mobilebytelabs/kmptoolkit/firebase/FirebaseInitProvider.kt
@therajanmaurya therajanmaurya changed the title cmp-firebase commonMain feat(cmp-firebase): fully-commonMain programmatic Firebase init via one FirebaseConfig Aug 21, 2026
@therajanmaurya therajanmaurya changed the title feat(cmp-firebase): fully-commonMain programmatic Firebase init via one FirebaseConfig feat(cmp-firebase): programmatic commonMain Firebase init via FirebaseKit.initialize(config) Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant