Hey all, I’ve tried to create a library project w...
# multiplatform
h
Hey all, I’ve tried to create a library project which depends on firebase-kotlin-sdk and when building klib
gradlew :shared:build
it failed because of
Copy code
> Task :shared:linkPodReleaseFrameworkIosArm64 FAILED
e: Compilation failed: Linking globals named 'kniprot_cocoapods_FirebaseAuth0_FIRUserInfo': symbol multiply defined!

 * Source files: 
 * Compiler version: 2.1.21-RC
 * Output kind: FRAMEWORK

e: java.lang.Error: Linking globals named 'kniprot_cocoapods_FirebaseAuth0_FIRUserInfo': symbol multiply defined!
I got it fixed by defining the following into cocoapods block:
Copy code
cocoapods {
        version = "10"
        ios.deploymentTarget = libs.versions.ios.deploymentTarget.get()
        framework {
            baseName = "FirebaseFirestoreXXX"
            isStatic = !enableFirebasePodsForTests
        }
Ie. added
isStatic
whenever not running tests from Android Studio and renaming
baseName
to something else than `FirebaseFirestore`as I copied the configuration from the firebase-kotlin-sdk project. This fixed it yesterday but today for whatever reason I’m back to the same error about symbol multiply defined. Any pointers would be helpful. Running tests from Android Studio work fine. I can build an XCFramework fine, but klib fails again. Any help would be appreciated, thanks.
a
Hi, can you provide a minimal reproducer project?
h
Hi, I made a minimal sample (attached), it had the same issue but when I removed the below dependency to FirebaseAuth, it compiles fine:
Copy code
pod("FirebaseAuth") {
    linkOnly = enableFirebasePodsForTests
    version = libs.versions.firebase.cocoapods.get()
    extraOpts += listOf("-compiler-option", "-fmodules")
}
a
So, your primary goal is to create an xcframework with firebase-kotlin-sdk?
h
Eventually but not in this library (I forgot the XCFramework part there, it works). I want to create klib so I can import it to another KMP library but the compilation fails if I have FirebaseAuth included as a dependency which is required by some tests
a
You need to run tests in the lib? Which tests?
h
We wrap firestore into a persistence service and test against the firebase emulator that our wrapper functions work along with document to object mapping
a
I would recommend to use the following approach: 1. Libaray "A", which have a dependency on firebase-kotlin-sdk. No cocoapods or xcframeworks here 2. Consumer project "B", consumes the library "A", adds a cocoapods dependency on native ios Firebase libs. Then you should be able to run tests from B
h
Ah, you are correct that it compiles the klib without cocoapods altogether, didn’t realize that. Thanks! We can include them only for the tests when needed.