Hi, I'm trying to follow <this tutorial >to add `f...
# multiplatform
t
Hi, I'm trying to follow this tutorial to add
firebase-kotlin-sdk
to the iOS side of my KMM project but hitting a linking error I can't resolve. Specifically, the tutorial has me add the official
FirebaseFirestore
framework (from
firebase-ios-sdk
) to my iOS project since
firebase-kotlin-sdk
doesn't automatically resolve transitive dependencies for iOS. I added that framework to the iOS project and it built normally. Then I added the following lines to my
shared
library `build.gradle.kts`:
Copy code
kotlin { sourceSets { commonMain.dependencies {
            // next line is the problem
            implementation("dev.gitlive:firebase-firestore:1.8.1")
            implementation("dev.gitlive:firebase-common:1.8.1")
and now iOS builds fail to link:
Copy code
ld: warning: ignoring duplicate libraries: '-ldl'
ld: framework 'FirebaseFirestore' not found

> Task :shared:linkDebugFrameworkIosSimulatorArm64 FAILED
error: Compilation finished with errors
The build log doesn't give any more detail but I've narrowed it down to the
dev.gitlive:firebase-firestore
dependency since commenting out that line un-breaks the build. Is there any way to get more info on exactly what's failing? As far as I can tell, the iOS project (and the app target, specifically) include
FirebaseFirestore
among the linked frameworks and I don't see any download error. I already have been using
firebase-ios-sdk
and the other products (eg,
FirebaseAuth
) without a problem on iOS. I'd greatly appreciate any help. Thanks!
e
Did you try to add something like this in the MainViewController file:
Copy code
fun initialise() {
    Firebase.initialize()
    Firebase.analytics.setAnalyticsCollectionEnabled(true)
}
and this call it from iOSApp.swift file:
Copy code
@main
struct iOSApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    init() {
        MainViewControllerKt.initialise()
    }
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
t
yeah, I've got that. It looks like this is failing before that would matter (during link). I'm not actually calling any of the API in
firebase-kotlin-sdk
yet
so, just including
firebase-kotlin-sdk
in my
commonMain
dependencies is causing this link error. The build output in Xcode is so massive I'm having trouble even finding the actual
ld
link command
e
did you try with 2.1.0 version?
t
good idea! It changes the error:
Copy code
ld: framework 'FirebaseCore' not found
which seems like it should just be a matter of adding that product to the framework dependencies but that isn't an option unlike
FirebaseAuth
,
FirebaseFirestore
, etc. Might be internal
e
🤞
t
I've tried every possible combination and nothing seems to work 😕 I finally see
FirebaseCore
as an option to add as a framework but it's still unavailable at link time
hmm, it seems like this may be a bit of a known problem: https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/499