GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.17k stars 155 forks source link

Firebase Auth not able to build for iOS #577

Closed dinesh-thiyagarajan closed 3 months ago

dinesh-thiyagarajan commented 3 months ago

ld: warning: Could not find or use auto-linked framework 'FirebaseAuth': framework 'FirebaseAuth' not found ld: warning: Could not find or use auto-linked framework 'FirebaseCore': framework 'FirebaseCore' not found Undefined symbols for architecture arm64: "_OBJCCLASS$_FIRAuth", referenced from: in ComposeApp2724 ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

On adding Firebase Auth as a separate module in compose multi platform app, was not able to build the app for iOS, but was able to do so in Android

timhuang1018 commented 3 months ago

@dinesh-thiyagarajan how did you solve this? I just ran into same error

dinesh-thiyagarajan commented 3 months ago

Hi @timhuang1018 Open the iosApp (which is under the root directory) folder in xcode.

  1. Click on File -> Add package Dependencies. In the search option search for https://github.com/firebase/firebase-ios-sdk and select firebase-ios-sdk and click on add package
  2. Come back to android studio

`import SwiftUI import Firebase

class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { FirebaseApp.configure()

    return true
}

}

@main struct iOSApp: App {

@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

var body: some Scene {
    WindowGroup {
        ContentView()
    }
}

}`

Paste the above code in iOSApp.swift file (not able to render the code here properly, but copy paste the code it should work fine), here we are initializing the firebase. also make sure you have added the GoogleService-Info.plist file inside the root/iosApp/iosApp/GoogleService-Info.plist

timhuang1018 commented 3 months ago

ohh I could work now! @dinesh-thiyagarajan appreciate for all these details!