Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[firebase_core] Firebase.initializeApp with demoProjectId crashes on iOS with SIGABRT (FIRInstallations validateAPIKey) - Follow-up to locked #17788

Cerrado
#18,790 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@SelaseKay ya está trabajando en esto.

Desde el 13/10/2026.

  • #18792 de @SelaseKay — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
dart, ios
Área
mobile

Línea de trabajo

Start in firebase_core/lib/src/firebase.dart, where demoProjectId builds the FirebaseOptions with the hardcoded apiKey '12345'. Reproduce with the linked repro project on an iOS simulator to see the SIGABRT from FIRInstallations validateAPIKey. Pull request #18792 already targets this, so check it before starting. Done means the demo options pass validation on Apple platforms and the repro app launches without crashing.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Needs Attention platform: ios plugin: core reproduced type: bug type: crash
Description

This is a follow-up to locked issue #17788. I have created a clean, minimal reproduction project with no remote Firebase project, no GoogleService-Info.plist, and no google-services.json:
👉 Reproduction Repository: https://github.com/akurnaz/flutterfire_repro

The issue is that Firebase.initializeApp(demoProjectId: '...') crashes natively on iOS (EXC_CRASH (SIGABRT) / Abort trap: 6) as soon as any package that depends on FirebaseInstallations (e.g., firebase_crashlytics, firebase_auth, or firebase_messaging) is present.

Steps to Reproduce
  1. Clone the reproduction repo: git clone https://github.com/akurnaz/flutterfire_repro.git
  2. Run on an iOS Simulator: flutter run
  3. The application crashes immediately on startup.

Alternatively, in any fresh Flutter app:

  • Add firebase_core: ^4.15.0 and firebase_crashlytics: ^5.4.0 (which pulls in FirebaseInstallations).
  • Call await Firebase.initializeApp(demoProjectId: 'demo-template'); in main().
Crash Stack Trace
Termination: SIGNAL (Abort trap: 6 / SIGABRT)
CoreFoundation - __exceptionPreprocess
libobjc.A.dylib - objc_exception_throw
Runner - +[FIRInstallations validateAPIKey:]
Runner - +[FIRInstallations validateAppOptions:appName:]
Runner - -[FIRInstallations initWithAppOptions:appName:installationsIDController:prefetchAuthToken:]
Runner - -[FIRInstallations initWithApp:]
Runner - __40+[FIRInstallations componentsToRegister]_block_invoke
Runner - -[FIRComponentContainer instantiateInstanceForProtocol:withBlock:]
Runner - -[FIRComponentContainer instanceForProtocol:]
Runner - -[FIRComponentContainer instantiateEagerComponents]
Runner - +[FIRApp configureWithName:options:]
Runner - FLTFirebaseCorePlugin.initializeApp(appName:initializeAppRequest:completion:)
Root Cause
  1. In firebase_core/lib/src/firebase.dart, demoProjectId sets a hardcoded dummy API key:
resolvedOptions = FirebaseOptions(
  apiKey: '12345',
  appId: '1:1:$platformString:1',
  messagingSenderId: '',
  projectId: demoProjectId,
);
  1. In the iOS native SDK (firebase-ios-sdk), FIRInstallations.m strictly validates that the API key is 39 characters and begins with A:
+ (void)validateAPIKey:(nullable NSString *)APIKey {
  if (APIKey.length != kExpectedAPIKeyLength) { // kExpectedAPIKeyLength = 39
    [validationIssues addObject:@"API Key length must be 39 characters"];
  }

  if (![[APIKey substringToIndex:1] isEqualToString:@"A"]) {
    [validationIssues addObject:@"API Key must start with `A`"];
  }
  
  if (validationIssues.count > 0) {
    [NSException raise:kFirebaseInstallationsErrorDomain format:...];
  }
}
  1. Because '12345' fails this validation, an uncaught NSException is thrown, resulting in an uncatchable SIGABRT crash on iOS.
Suggested Fix

In firebase_core/lib/src/firebase.dart, format the dummy apiKey to be a 39-character string starting with A on Apple platforms:

apiKey: (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS)
    ? 'AIzaSy0000000000000000000000000000000'
    : '12345',
Lenguaje dominante
Dart
Estrellas
9.3k
Forks
4.1k
Merge medio
2 d 7 h
PR fusionados (30 d)
47

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de firebase/flutterfire

Todos los issues de firebase/flutterfire

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.