This guide helps you migrate from earlier versions (v1.0.0 or v1.0.1) to v1.0.2, which includes:
- ✨ Desktop/JVM support
- 🚀 Android auto-initialization
- 📱 Simplified iOS setup
- 🔧 Better error messages
- Update dependency version to
1.0.2 - Android: Remove manual
ActivityHoldercode - iOS: (Optional) Use new bridge template
- Desktop: Add if needed
- Test authentication flows
- Update documentation references
v1.0.2 introduces automatic initialization via ContentProvider - you no longer need to manually manage ActivityHolder.current!
// build.gradle.kts
dependencies {
implementation("dev.com3run:firebase-auth-kmp:1.0.2") // Update version
}BEFORE (v1.0.0/v1.0.1):
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ActivityHolder.current = this // ❌ Remove this
setContent {
App()
}
}
override fun onDestroy() {
super.onDestroy()
ActivityHolder.current = null // ❌ Remove this
}
}AFTER (v1.0.2):
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ✅ No ActivityHolder code needed!
setContent {
App()
}
}
// ✅ No onDestroy override needed!
}- Run your app
- Test Google Sign-In (if you use it)
- Verify no crashes or initialization errors
That's it! Your Android app is now using auto-initialization.
v1.0.2 provides a ready-to-use bridge template that's easier to set up and maintain.
If your existing FirebaseAuthBridge.swift works fine, you don't need to change anything. v1.0.2 is fully compatible with your existing bridge.
The new template includes:
- Better documentation
- Improved error handling
- Consistent code style
- Future-proof structure
-
Backup your current bridge (just in case)
-
Get the new template:
- Download from:
firebase-auth-kmp/FirebaseAuthBridge.swift.template - Or copy from the library package
- Download from:
-
Replace your bridge:
# In your iOS app rm iosApp/iosApp/FirebaseAuthBridge.swift cp firebase-auth-kmp/FirebaseAuthBridge.swift.template iosApp/iosApp/FirebaseAuthBridge.swift -
Verify initialization in AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions...) -> Bool { FirebaseApp.configure() FirebaseAuthBridge.shared.start() // ✅ Same as before return true }
-
Test:
- Run your iOS app
- Test all auth flows
- Verify Google/Apple Sign-In works
No code changes needed in your Kotlin code!
If you want to add desktop support to your app:
// composeApp/build.gradle.kts
kotlin {
androidTarget { ... }
// Add this:
jvm("desktop") {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
iosArm64()
iosSimulatorArm64()
}// composeApp/src/desktopMain/kotlin/YourPackage/main.kt
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
fun main() {
application {
Window(onCloseRequest = ::exitApplication, title = "Your App") {
App()
}
}
}Create firebase-config.json in project root:
{
"apiKey": "YOUR_FIREBASE_API_KEY",
"projectId": "your-project-id"
}./gradlew :composeApp:runSee agents/desktop-setup.md for full desktop documentation.
v1.0.2 is fully backward compatible. All existing APIs work exactly the same:
// These APIs are unchanged:
authRepository.signInWithEmailAndPassword(email, password)
authRepository.signInWithGoogle(idToken)
authRepository.signInAnonymously()
authRepository.signOut()
authRepository.authState.collect { ... }// Desktop uses the same API:
val authRepository = AuthRepository(platformAuthBackend())
// Works on all platforms (Android, iOS, Desktop)
val result = authRepository.signInWithEmailAndPassword(email, password)Problem: Google Sign-In fails after removing ActivityHolder code.
Solution: The auto-initializer handles this automatically, but if you see issues:
-
Clean and rebuild:
./gradlew clean ./gradlew :composeApp:assembleDebug
-
Verify your
google-services.jsonis present -
Check SHA-1 fingerprint is registered in Firebase Console
Problem: FirebaseAuthBridge.swift.template file not found.
Solution:
The template is in the library package:
firebase-auth-kmp/FirebaseAuthBridge.swift.template
Or get it from the GitHub repository.
Problem: Desktop app crashes with "Firebase API key not found".
Solution:
- Create
firebase-config.jsonin your project root (not in src/) - Or set environment variable:
export FIREBASE_API_KEY="your-key"
- App launches successfully
- Email/password sign-in works
- Google Sign-In works (if applicable)
- Anonymous sign-in works
- Sign-out works
- Auth state updates correctly
- No
ActivityHolderreferences in your code
- App launches successfully
- Bridge initializes (check console for "✅ Firebase Auth KMP Bridge initialized")
- Email/password sign-in works
- Google Sign-In works (if applicable)
- Apple Sign-In works (if applicable)
- Sign-out works
- Auth state updates correctly
- App launches successfully
- Firebase config loads correctly
- Email/password sign-in works
- Anonymous sign-in works
- Sign-out works
- Auth state updates correctly
If you need to rollback to v1.0.0/v1.0.1:
-
Downgrade dependency:
implementation("dev.com3run:firebase-auth-kmp:1.0.1") -
Re-add
ActivityHoldercode:override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ActivityHolder.current = this // ... } override fun onDestroy() { super.onDestroy() ActivityHolder.current = null }
-
Clean and rebuild
-
Downgrade dependency:
implementation("dev.com3run:firebase-auth-kmp:1.0.1") -
Keep your existing bridge (it's compatible)
-
Rebuild
If you encounter issues during migration:
-
Check the documentation:
-
Review common issues:
-
Get support:
- ✅ Zero boilerplate - No manual initialization
- ✅ Fewer bugs - Can't forget to set/clear ActivityHolder
- ✅ Cleaner code - Less code to maintain
- ✅ Automatic lifecycle - Library handles everything
- ✅ Better template - Well-documented, ready to use
- ✅ Easier setup - Copy-paste instead of writing from scratch
- ✅ Future-proof - Stays updated with library changes
- ✅ New platform - Reach desktop users
- ✅ Unified API - Same code works everywhere
- ✅ Easy config - Simple JSON file
Happy migrating! 🚀
If you find this guide helpful, please ⭐ star the repo!