Skip to content

Instantly share code, notes, and snippets.

View KevinBlock-GC's full-sized avatar

Kevin Block KevinBlock-GC

View GitHub Profile
@main
struct iOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
import Foundation
import UIKit
import ComposeApp
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("AppDelegate: didFinishLaunchingWithOptions - Calling KMP init.")
// Call your kmp initializer kotlin code!
import cocoapods.FirebaseCore.FIRApp
import kotlinx.cinterop.ExperimentalForeignApi
@OptIn(ExperimentalForeignApi::class)
fun onDidFinishLaunchingWithOptions() {
println("KMP Initializer: Starting setup...")
FIRApp.configure() // Call Firebase configure
println("KMP Initializer: Firebase project ID: ${FIRApp.defaultApp()?.options!!.projectID()}")
}
// Use the built in cocoapods support to bring in firebase libraries
kotlin {
// Remove the framework block if its here
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "My compose multiplatform app"
version = "1.0"
echo "Copying GoogleService located at ${GOOGLE_SERVICE}"
if [ -z "${GOOGLE_SERVICE}" ]; then
echo "GOOGLE_SERVICE is unset or set to the empty string"
exit 1
fi
if [ ! -f "${GOOGLE_SERVICE}" ]; then
echo "GOOGLE_SERVICE does not exist"
exit 1
android {
// Other configurations...
buildTypes {
getByName("debug") {
isMinifyEnabled = false
applicationIdSuffix = ".dev"
versionNameSuffix = "-DEBUG"
}
getByName("release") {
isMinifyEnabled = true
plugins {
// Other plugins
alias(libs.plugins.googleServices)
}
sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(project.dependencies.platform(libs.android.firebase.bom))
implementation(libs.android.firebase.auth)
[versions]
firebase-bom = "33.14.0"
google-services-plugin = "4.4.2"
[libraries]
android-firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" }
# Optional, include if using firebase auth
android-firebase-auth = { module = "com.google.firebase:firebase-auth" }
# Optional, include if using firebase analytics
android-firebase-analytics = { module = "com.google.firebase:firebase-analytics" }