Mehdi.ncb
Mehdi.ncb

Reputation: 372

KMP iOS Build Error - FirebaseMessaging symbol multiply defined

I'm experiencing build errors in my Kotlin Multiplatform project when integrating Firebase Messaging for iOS. The error occurs during the linking phase:

CopyCompilation failed: Linking globals named 'knifunptr_cocoapods_FirebaseMessaging1_FIRMessagingErrorDomain_getter': symbol multiply defined!

Project Setup

I'm using:

Kotlin 2.1.10
Compose Multiplatform 1.8.0-alpha03
iOS deployment target 15.4
Firebase GitLive library version 2.1.0
KMPNotifier version 1.4.0

build.gradle.kts

kotlin {
// Android and iOS targets configuration

cocoapods {
    summary = "Description for shared module"
    homepage = "Link to the shared module"
    version = "1.0"
    ios.deploymentTarget = "15.4"
    podfile = project.file("../iosApp/Podfile")
    framework {
        baseName = "ComposeApp"
        isStatic = true
        export(libs.kmp.notifier)
    }

    // This line is commented out but might be part of the issue
    // pod("FirebaseMessaging")

    pod("GoogleMaps") {
        version = libs.versions.pods.google.maps.get()
        extraOpts += listOf("-compiler-option", "-fmodules")
    }

    pod("Google-Maps-iOS-Utils") {
        moduleName = "GoogleMapsUtils"
        version = libs.versions.pods.google.ios.maps.utils.get()
        extraOpts += listOf("-compiler-option", "-fmodules")
    }
}

// Dependencies include FirebaseMessaging
sourceSets {
    commonMain.dependencies {
        // Firebase
        implementation(libs.gitlive.firebase.firestore)
        implementation(libs.gitlive.firebase.auth)
        implementation(libs.gitlive.firebase.messaging)
        
        // Other dependencies...
    }
  }
}
Podfile
rubyCopyplatform :ios, '15.4'
target 'iosApp' do
  use_frameworks!

  pod 'composeApp', :path => '../composeApp'
  pod 'GoogleMaps', '9.3.0'
  pod 'Google-Maps-iOS-Utils', '6.1.0'
  
  # FirebaseMessaging is not explicitly listed here
end

I've tried:

What's causing this symbol duplication error with FirebaseMessaging and how can I fix it? Is there a specific configuration I need for Firebase Messaging with KMP projects?

Upvotes: 1

Views: 27

Answers (0)

Related Questions