:wave: :android-wave: Hello, I'm hitting the error...
# multiplatform
m
πŸ‘‹ πŸ‘‹ Hello, I'm hitting the error
ld: framework 'FirebaseCore' not found
when trying to run my test suite on iOS with the command
./gradlew iosSimulatorArm64Test
. I have tried many things already without any success, and I would be greatly thankful if I could get a hand πŸ™ 🧡
I'm using Gitlive to integrate with Firestore and Firebase Auth into our app. I'm building a static XCFramework from the
umbrella
module, and the full app builds and works as expected (I'm adding the Firebase dependencies on both Android and iOS from the main apps, as Gitlive does not include them).
However, when trying to run the iOS tests, the compiler cannot find FirebaseCore and fails in the execution of
:feature:xxxxxx:linkDebugTestIosSimulatorArm64
I have tried:
1. Downloading the Firebase frameworks manually from here and adding them into my project to use them only during the test task and pass them to the linkerOpts:
Copy code
// 1- Find libraries
val testLibsDir = rootDir.resolve("test-libs/firebase")
val firebaseFrameworkPaths =
    testLibsDir.listFiles()
        ?.filter { it.isDirectory }
        ?.flatMap { directory ->
            directory.listFiles()?.filter { it.isDirectory } ?: emptyList()
        }
    ?.map { "-F$it" }
    ?: emptyList()

framework {
    //...


    // 2- Add all libraries with linkerOpts as seen here <https://github.com/leoull/KMM-FirebaseAuth?tab=readme-ov-file#issuecomment-1106932297>
    firebaseFrameworkPaths.forEach {
        linkerOpts(it)
    }
    linkerOpts("-ObjC")
}
The structure of my libs folders looks like:
Copy code
my-project/
└── test-libs/
    └── firebase/
        β”œβ”€β”€ FirebaseCore/
        β”‚   └── ios-arm64_x86_64-simulator/
        β”‚       └── FirebaseCore.framework/
        β”œβ”€β”€ FirebaseAuth/
        β”‚   └── ios-arm64_x86_64-simulator/
        β”‚       └── FirebaseAuth.framework/
        └── FirebaseFirestore/
            └── ios-arm64_x86_64-simulator/
                └── FirebaseFirestore.framework/
I confirmed that I was getting the right paths for the libraries, and even tried to hardcode the paths with no luck. I also tried adding:
Copy code
getTest("DEBUG").apply {
    linkerOpts("-F${rootProject.rootDir.absolutePath}/test-libs/firebase/FirebaseCore")
    linkerOpts("-F${rootProject.rootDir.absolutePath}/test-libs/firebase/FirebaseAuth")
    linkerOpts("-F${rootProject.rootDir.absolutePath}/test-libs/firebase/FirebaseFirestore")
    linkerOpts("-ObjC")
}
2. I also tried adding Cocoapods (even though I wanted to avoid this because of the long compilation times), and follow this approach. No luck 😞
3. I also tried doing this that I got from this Sentry issue. No luck either 😞
Copy code
it.compilations.all {
    if (compilationName == "test" && target.platformType == KotlinPlatformType.native) {
        compilerOptions.configure {
            freeCompilerArgs.add("-linker-options")
            freeCompilerArgs.add("-F/Users/marcel/Workspace/my-project/umbrella/build/cocoapods/synthetic/ios/build/Release-iphonesimulator/FirebaseAuthInterop")
            freeCompilerArgs.add("-F/Users/marcel/Workspace/my-project/umbrella/build/cocoapods/synthetic/ios/build/Release-iphonesimulator/FirebaseCore")
            freeCompilerArgs.add("-F/Users/marcel/Workspace/my-project/umbrella/build/cocoapods/synthetic/ios/build/Release-iphonesimulator/FirebaseAuth")
             freeCompilerArgs.add("-F/Users/marcel/Workspace/my-project/umbrella/build/cocoapods/synthetic/ios/build/Release-iphonesimulator/FirebaseFirestore")
        }
    }
}
r
hm, configuring linkerOpts against the local frameworks should work, that's what we do in the sentry plugin here: https://github.com/getsentry/sentry-kotlin-multiplatform/blob/20ac4496acc8a565b8b2[…]main/java/io/sentry/kotlin/multiplatform/gradle/SentryPlugin.kt I think you should specify the architecture as well, not only the framework dir, otherwise it doesn't know which arch to pick for the current kmp target:
Copy code
linkerOpts("-F${rootProject.rootDir.absolutePath}/test-libs/firebase/FirebaseCore/ios-arm64_x86_64-simulator")
m
Hey @romtsn thanks for the help and the reference to Sentry plugin code! I'm gonna give it another go next week, for the time being, we have had to disable iOS target unit tests and run them only on the Android target