All skills
firebase avatar

/firebase-basics

@073edf7
by firebasefirebase/skills461 stars
102

Provides foundational Firebase CLI setup, CLI installation, version checks (`firebase-tools@latest --version`), CLI login (including --no-localhost), project creation, project selection (`firebase use`), and app config file downloads (`google-services.json`, `GoogleService-Info.plist`). Use ONLY for CLI login, project creation/switching, or downloading app config files. Don't use for Firebase Hosting deploy, Firestore, Auth, App Hosting, Data Connect, Crashlytics, or Remote Config.

Use this Skill: https://skilld.dev/gh/firebase/skills/firebase-basics

This session only. Nothing lands on disk.

referencesios_setup.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Firebase iOS Setup Guide

⛔️ CRITICAL RULE: STATE MANAGEMENT (OBSERVATION VS COMBINE) ⛔️

When writing or updating SwiftUI code, you MUST prioritize the modern Swift Observation framework (@Observable macro and @State) as your default approach.

However, it is acceptable to use Combine (ObservableObject, @Published, @StateObject, @EnvironmentObject) under the following conditions:

  • The user explicitly asks you to use Combine.
  • There are strong signals in the existing codebase that the project is heavily relying on Combine.

If neither of those conditions are true, default to the Swift 5.9+ Observation framework.

⛔️ CRITICAL RULE: INITIALIZATION ORDER ⛔️

When using SwiftUI, you MUST ensure FirebaseApp.configure() is called BEFORE any Firebase-dependent state objects are initialized.

  • UNSAFE (CRASH): Declaring a @State (for @Observable) or @StateObject (for Combine) property in the root App struct if its initializer touches Firebase. Property initializers run before the App.init() body, meaning the object's init() will fire before Firebase is configured.
  • SAFE: Initialize Firebase in App.init() and pass your state objects into the sub-views (like ContentView), or use onAppear for delayed setup.

Failing to follow this will result in a fatal crash: Default FirebaseApp is not configured.

1. Create a Firebase Project and App (Automated)

Do not use the Firebase Console. Use the CLI to automate setup:

  1. Create the project: npx -y firebase-tools@latest projects:create
  2. Action: Read the Xcode project (.pbxproj or Info.plist) to determine the iOS bundle ID.
  3. Register the iOS app: npx -y firebase-tools@latest apps:create IOS <bundle-id>
  4. Fetch the config: npx -y firebase-tools@latest apps:sdkconfig IOS <App-ID>
  5. Save the output as GoogleService-Info.plist in your Xcode project folder. Ensure you remove any non-XML CLI output headers, and ensure the file is linked to the main application target.

2. Installation (Automated via Swift Package Manager CLI)

Do not use raw text parsing, sed, or Ruby scripts (like xcodeproj gem) to modify .pbxproj files directly.

Instead, use the xcode-project-setup skill. Load that skill using your tools to securely execute its native Swift package setup script. That skill handles installing the required SPM packages and safely linking the GoogleService-Info.plist file.

💡 TIP: ALWAYS USE THE LATEST SDK VERSION To ensure access to the latest features and security fixes, always check for the most recent version of the Firebase iOS SDK at https://github.com/firebase/firebase-ios-sdk/releases and use that version when adding the SPM dependency.

3. Initialization

Configure the shared FirebaseApp instance. You can do this either in a modern SwiftUI App structure or a traditional AppDelegate.

SwiftUI (Modern - SAFE PATTERN)

import SwiftUI
import FirebaseCore

@main
struct YourApp: App {
  // ⛔️ FATAL CRASH: @State private var auth = AuthManager()
  // property initializers run before init(), causing FirebaseApp not configured error
  @State private var authManager: AuthManager

  init() {
    // ✅ SAFE: This runs FIRST
    FirebaseApp.configure()
    
    // ✅ SAFE: Initialize state ONLY AFTER Firebase is configured
    _authManager = State(initialValue: AuthManager())
  }

  var body: some Scene {
    WindowGroup {
      ContentView()
        .environment(authManager)
    }
  }
}

AppDelegate (Traditional / UIKit)

import UIKit
import FirebaseCore

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    // ✅ SAFE: Always the first line in didFinishLaunching
    FirebaseApp.configure()
    return true
  }
}

Source: SKILL.md on GitHub

2 warningstoday5 checks · Risk SAFE
  • Gen Agent Trust Hubtoday

    This skill provides a comprehensive suite of instructions for initializing and managing Firebase projects across various development environments. It follows standard industry practices for setting up cloud infrastructure, including downloading tools from official sources (npm, Google, GitHub) and configuring local environments. The 'low' verdict is assigned due to the inherent attack surface for indirect prompt injection when processing user-supplied identifiers like Project IDs in shell commands, though no malicious intent was detected.

  • Sockettoday

    1 alert: gptAnomaly

  • Snyktoday

    Risk: LOW · No issues

  • Runlayer6mo

    2 files scanned · No issues

  • ZeroLeaks5mo

    1 finding · Score: 69/100

Signed by skilld at 073edf7. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 2 months ago
metadata
{
  "category": "CloudInfrastructureAndServices"
}
  • firebase
  • firebase-cli
  • authentication
  • project-setup
  • google-services
  • web
  • android
  • ios

README badge

README badge for firebase/skills/firebase-basics

Provides foundational Firebase CLI setup, authentication, and project management for initializing Firebase environments. Use for checking the Firebase CLI version, logging in, setting active projects, and retrieving config files like google-services.json for Android or GoogleService-Info.plist for iOS.

Generated from the current SKILL.md.

Does this skill handle Firebase authentication setup?
Yes. It covers Firebase CLI authentication via `npx -y firebase-tools@latest login`, including the `--no-localhost` flag for environments without a browser.
What Firebase operations does this skill support?
It provides CLI-based workflows for checking Firebase CLI version, initializing Firebase environments, authenticating, managing active projects, and retrieving `google-services.json` and `GoogleService-Info.plist` config files for Android and iOS apps.
Can I use this skill to create a new Firebase project?
Yes. The skill includes the `npx -y firebase-tools@latest projects:create` command to create new projects with a globally unique project ID.
Does this skill work with Genkit?
The skill acknowledges Genkit usage and notes that the genkit-ai/skills package should be installed separately when using Genkit.

Generated from the current SKILL.md. These answers refresh after source changes.