Skip to content

About

A CLI helping configure Firebase for Kotlin Multiplatform / Compose Multiplatform applications quickly and easily

Topics

Resources

Stars

8 stars

Watchers

0 watching

Forks

Repository files navigation

kmpfire

kmpfire_cli

A CLI helping configure Firebase for Kotlin Multiplatform / Compose Multiplatform applications quickly and easily
Command: kmpfire — register Android / iOS Firebase apps and write native config from the terminal

Build GitHub release GitHub Repo stars License

A CLI to help with using Firebase in your Kotlin Multiplatform / Compose Multiplatform applications.

It wraps the Firebase CLI (firebase-tools) to register Android / iOS apps, write native service files, and track configuration in firebase.json.

Autodownload configuration files for Android and iOS apps, and patch the project files to use them.

LnyO34VlYKmxhYkx.mp4

Requirements

  • Firebase CLI installed and logged in (firebase login)
  • A KMP / CMP project root (settings.gradle.kts)
  • To build this repo: JDK 21+

Supported layouts

Layout Paths
New template shared/ + androidApp/ + iosApp/
Nested app/ (monorepo) app/shared/ + app/androidApp/ + app/iosApp/
Legacy composeApp/ + iosApp/

Platforms in v1: Android + iOS only (no desktop / web Firebase targets).


Install / run

curl (recommended)

curl -fsSL https://raw.githubusercontent.com/dungngminh/kmpfire_cli/main/install.sh | bash

Pin a release tag:

curl -fsSL https://raw.githubusercontent.com/dungngminh/kmpfire_cli/main/install.sh | bash -s -- v0.2.0

Installs into ~/.local/lib/kmpfire and links ~/.local/bin/kmpfire (adds that dir to your shell PATH if needed).

Homebrew

brew tap dungngminh/kmpfire_cli
brew install kmpfire

Requires the tap repo dungngminh/homebrew-kmpfire_cli (updated on each GitHub Release).

From a release archive

Download kmpfire-<os>-<arch>.tar.gz from Releases, extract, rename to kmpfire, and put it on your PATH.

kmpfire --help
# Footer shows: kmpfire <version>

From source (local development)

git clone https://github.com/dungngminh/kmpfire_cli.git
cd kmpfire_cli

# Fast JVM path (dev):
./gradlew jvmRun --args='--help'

# Native release binary (example: Apple Silicon):
./gradlew linkReleaseExecutableMacosArm64
./build/bin/macosArm64/releaseExecutable/kmpfire.kexe --help

Other native hosts: MacosX64, LinuxX64, LinuxArm64, MingwX64.


Default setup

From your KMP project root, run:

kmpfire configure

At a minimum this prompts for a Firebase project and platforms (android, ios).

No prompts (CI / scripts):

kmpfire configure --yes --project=<FIREBASE_PROJECT_ID>

kmpfire auto-detects:

  • Android applicationId from the androidApp Gradle file
  • iOS bundle id from project.pbxproj, or Compose Multiplatform *.xcconfig ($(TEAM_ID) resolved)

If no Firebase app matches, it creates one, then writes:

  • google-services.json (default under androidApp/ or nested app/androidApp/)
  • GoogleService-Info.plist (default under iosApp/…)
  • merges state into firebase.json → "kotlinMultiplatform"

Override package / bundle / paths when needed:

kmpfire configure --yes --project=<FIREBASE_PROJECT_ID> \
  --android-package-name=<ANDROID_PACKAGE_NAME> \
  --ios-bundle-id=<IOS_BUNDLE_ID> \
  --android-out=androidApp/google-services.json \
  --ios-out=iosApp/iosApp/GoogleService-Info.plist

Limit platforms:

kmpfire configure --yes --project=<FIREBASE_PROJECT_ID> --platforms=android,ios

Create the Firebase project if the id is missing from your account:

kmpfire configure --yes --project=<NEW_PROJECT_ID> --create-project

--yes flag

  • Uses detected platforms when --platforms is omitted
  • Requires --project (unless reusing an existing kotlinMultiplatform section)
  • Auto-reuses values from an existing firebase.json kotlinMultiplatform section when present

--project flag

Selects the Firebase project and skips the project picker prompt.

Reuse existing firebase.json

If firebase.json already has a kotlinMultiplatform section, interactive configure asks whether to reuse those values (project, platforms, package/bundle, outs). Answer yes to prefill; --yes reuses automatically.


Multi build configuration / flavors

Important: kmpfire does not auto-detect flavors. Run configure once per flavor with explicit flags.

Use --flavor=<name> to store the entry under platforms.*.buildConfigurations.<name> (default entry is platforms.*.default).

Android

kmpfire configure --platforms=android \
  --flavor=dev \
  --android-package-name=your.application.id.dev \
  --android-out=androidApp/src/dev/google-services.json \
  --project=<FIREBASE_PROJECT_ID> --yes

Place each google-services.json where the Google Services plugin expects it for that flavor/build type. Match the Firebase Android app’s application id to that flavor.

Important: pass --android-package-name for flavors; otherwise kmpfire detects the default applicationId only.

iOS

kmpfire configure --platforms=ios \
  --flavor=Debug-dev \
  --ios-bundle-id=your.bundle.id.dev \
  --ios-out=iosApp/config/dev/GoogleService-Info.plist \
  --project=<FIREBASE_PROJECT_ID> --yes

Important: pass --ios-bundle-id for flavors; otherwise kmpfire detects the default bundle id from pbxproj / .xcconfig only. iOS plist writes / Xcode patching are best-effort from a macOS environment.

Example: debug + release style paths

# debug / default
kmpfire configure --yes --project=your-project-id --platforms=android,ios \
  --android-out=androidApp/src/debug/google-services.json \
  --android-package-name=com.example.myapp.debug \
  --ios-out=iosApp/debug/GoogleService-Info.plist \
  --ios-bundle-id=com.example.myapp.ios.debug

# release flavor
kmpfire configure --yes --project=your-project-id --platforms=android,ios \
  --flavor=release \
  --android-out=androidApp/src/release/google-services.json \
  --android-package-name=com.example.myapp.release \
  --ios-out=iosApp/release/GoogleService-Info.plist \
  --ios-bundle-id=com.example.myapp.ios.release

kmpfire reconfigure

After changing Firebase products in the console (or to refresh configs), rewrite service files from stored paths:

kmpfire reconfigure

This uses firebase.json → kotlinMultiplatform to update each fileOutput in place (all default + buildConfigurations entries). Limit to one flavor:

kmpfire reconfigure --flavor=dev

Optional Gradle patch (Google Services on androidApp; GitLive on shared when --sdk=gitlive):

kmpfire reconfigure --deps
# or on first configure:
kmpfire configure --yes --project=<ID> --deps --sdk=gitlive

State: firebase.json → kotlinMultiplatform

kmpfire stores configuration in firebase.json under a kotlinMultiplatform section.

{
  "kotlinMultiplatform": {
    "projectId": "my-firebase",
    "sdk": "gitlive",
    "layoutKind": "app-nested",
    "platforms": {
      "android": {
        "default": {
          "appId": "1:…:android:…",
          "fileOutput": "app/androidApp/google-services.json",
          "packageNameOrBundleId": "com.example.app"
        },
        "buildConfigurations": {
          "dev": {
            "appId": "1:…:android:dev",
            "fileOutput": "app/androidApp/src/dev/google-services.json",
            "packageNameOrBundleId": "com.example.app.dev"
          }
        }
      },
      "ios": {
        "default": {
          "appId": "1:…:ios:…",
          "fileOutput": "app/iosApp/iosApp/GoogleService-Info.plist",
          "packageNameOrBundleId": "com.example.app"
        }
      }
    }
  }
}

fileOutput paths are relative to the project root.


Useful flags

Flag Meaning
--project / -P Firebase project id
--project-dir KMP root (directory with settings.gradle.kts)
--platforms=android,ios Platforms (omit → interactive multi-select)
--flavor Named buildConfiguration (omit → default)
--yes / -y Non-interactive defaults / reuse existing section
--create-project Create Firebase project when id is missing
--sdk gitlive|native Affects --deps / stored in state
--deps Patch Gradle plugins / deps
--android-package-name Override applicationId
--ios-bundle-id Override PRODUCT_BUNDLE_IDENTIFIER
--android-out / --ios-out Custom service file paths
--dry-run Print actions only
--version / -V Show CLI version

Caveats

  • Prefer native service files for Android (google-services.json) and iOS (GoogleService-Info.plist). kmpfire intentionally does not generate Kotlin FirebaseOptions source.
  • Google Services Gradle plugin applies on androidApp only, never on shared.
  • --deps is opt-in; Gradle / pbxproj patches soft-fail (warn, do not abort successful config writes).
  • Firebase CLI’s published JSON schema does not list kotlinMultiplatform; rare strict validation may warn.
  • iOS configuration assumes a macOS host for sensible Xcode / plist workflow.

Contributing

git clone https://github.com/dungngminh/kmpfire_cli.git
cd kmpfire_cli
./gradlew jvmTest
./gradlew jvmRun --args='configure --help'
  1. Fork this repository
  2. Create a branch and make your changes
  3. Open a Pull Request

License

MIT — see LICENSE

About

A CLI helping configure Firebase for Kotlin Multiplatform / Compose Multiplatform applications quickly and easily

Topics

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages