Hi everyone I am trying to use Crashlytics for iOS...
# multiplatform
r
Hi everyone I am trying to use Crashlytics for iOS in a multiplatform project. I added the dependency via SPM and added the gitlive-firebase-sdk. This works fine when building the app via Xcode, but when trying to run tests, it fails to link the framework. I tried to use the workaround described in the readme of the gitlive-firebase-sdk that suggests using cocoapods for this, but this is a pain and the setup leads to countless other issues. Is there an easy way of fixing this? I tried using spm4kmp plugin, but linking for tests doesn‘t work.
f
Hi! Look on the tips section of the website, you will get your answer
r
Ok, thanks. Will take a look at these
f
Testing is important :), it was not easy to find a good solution
r
I totally agree. By the way, thanks for the great work. Unfortunately I have still the same issue that states
ld: warning: ignoring duplicate libraries: '-ldl'
ld: framework 'FirebaseCore' not found
I added the dependencies as followed:
Copy code
swiftPackageConfig {
    create("nativeDeps") {
        minIos = "15"
        linkerOpts = listOf("-ObjC")

        dependency {
            remotePackageVersion(
                url = URI("<https://github.com/firebase/firebase-ios-sdk.git>"),
                version = "12.2.0",
                packageName = "firebase-ios-sdk",
                products = {
                    add(ProductName("FirebaseCore"), exportToKotlin = false)
                    add(ProductName("FirebaseCrashlytics"), exportToKotlin = false)
                },
            )
        }
    }
}
and the targets for ios are like this:
Copy code
listOf(
            // iosX64(),
            iosArm64(),
            iosSimulatorArm64()
        ).forEach { iosTarget ->
            iosTarget.binaries.getTest("debug").apply {
                val scratchDir =
                    if (target.name == "iosSimulatorArm64") {
                        "arm64-apple-ios-simulator"
                    } else {
                        "arm64-apple-ios"
                    }
                linkerOpts +=
                    listOf(
                        "-rpath",
                        "${projectDir.path}/build/spmKmpPlugin/nativeDeps/scratch/$scratchDir/release/",
                    )
                freeCompilerArgs +=
                    listOf(
                        "-Xoverride-konan-properties=osVersionMin.ios_simulator_arm64=16.0",
                    )
            }

            iosTarget.binaries.framework {
                baseName = "ComposeApp"
                isStatic = true
            }

            iosTarget.compilations {
                val main by getting {
                    // Choose the cinterop name
                    cinterops.create("nativeDeps")
                }
            }
        }
Am I missing something?
f
yes, you new to a missing linkerOpts value that link the FirebaseCore library
Compile the Test target require to manually link the external depenency
r
@François after investigating a litle more, I found one of your old posts that mentioned problems with the gitlive-kotlin-sdk. after removing it and building my own firebase-wrapper it works perfectly. Thanks again for the support and the great work
🙌 1