firebase-kotlin-sdk: "framework not found FirebaseCore" build error

I’m getting such error while trying to build my multiplatform project on macos:

> Task :linkMultiCoreDebugFrameworkIos FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: framework not found FirebaseCore

My build.gradle file:

buildscript {
    ext {
        kotlin_version = "1.3.72"
        coroutine_version = "1.3.2"
        coroutines_play_services = "1.3.5"
        serializer_version = "0.13.0"
        androidx_lifecycle_version = "2.2.0"
        moko_mvvm_version = "0.6.0"
        mockk_version = "1.9.3"
        firebase_auth_version = "0.2.0"
    }
    repositories {
        google()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.android.tools.build:gradle:3.6.3"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'

repositories {
    mavenLocal()
    jcenter()
    google()

    maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
}

group 'com.aramso.curtains.backend'
version '0.0.1'

apply plugin: 'maven-publish'

def kotlinPluginId = 'org.jetbrains.kotlin.multiplatform'
final hasPlugin = project.getPlugins().hasPlugin(kotlinPluginId);
if (hasPlugin) {
    final Plugin plugin = project.getPlugins().getPlugin(kotlinPluginId)
    println 'Plugin already applied - version ' + plugin.properties['kotlinPluginVersion']
} else {
    apply plugin: "org.jetbrains.kotlin.multiplatform"
}

android {
    compileSdkVersion(29)

    defaultConfig {
        minSdkVersion(21)
        targetSdkVersion(29)
    }

    sourceSets {
        main {
            manifest.srcFile 'src/androidMain/AndroidManifest.xml'
            java.srcDirs = ['src/androidMain/kotlin']
            res.srcDirs = ['src/androidMain/resources']
        }
        test {
            java.srcDirs = ['src/androidTest/kotlin']
            res.srcDirs = ['src/androidTest/resources']
        }
    }

    testOptions.unitTests.includeAndroidResources = true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}

kotlin {
    targets {
        final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
                              ? presets.iosArm64 : presets.iosX64

        fromPreset(iOSTarget, 'ios') {
            binaries {
                framework('MultiCore')
            }
        }

        fromPreset(presets.android, 'android')
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')

                // COROUTINES
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutine_version"
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutines_play_services"

                // MOKO - MVVM
                api "dev.icerock.moko:mvvm:$moko_mvvm_version"

                // SERIALIZATION
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializer_version"

                // FIREBASE AUTH
                implementation "dev.gitlive:firebase-auth:$firebase_auth_version"
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')

                implementation "io.mockk:mockk:$mockk_version"
            }
        }
        androidMain {
            dependencies {
                implementation kotlin('stdlib')

                implementation "androidx.lifecycle:lifecycle-extensions:$androidx_lifecycle_version"
                implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"

                // COROUTINES
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"

                // SERIALIZATION
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializer_version"
            }
        }
        androidTest {
            dependencies {
                implementation kotlin('test')
                implementation kotlin('test-junit')
            }
        }
        iosMain {
        }
        iosTest {
        }
    }
}

configurations {
    compileClasspath
}

task packForXcode(type: Sync) {
    final File frameworkDir = new File(buildDir, "xcode-frameworks")
    final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
    final def framework = kotlin.targets.ios.binaries.getFramework("MultiCore", mode)

    inputs.property "mode", mode
    dependsOn framework.linkTask

    from { framework.outputFile.parentFile }
    into frameworkDir

    doLast {
        new File(frameworkDir, 'gradlew').with {
            text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
            setExecutable(true)
        }
    }
}

tasks.build.dependsOn packForXcode

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (16 by maintainers)

Most upvoted comments

I think you need to add the linkerOps to your binaries like

linkerOpts("-F${firebase-kotlin-sdk-folder/build}/Firebase/FirebaseAnalytics")

Hi. any idea where this ‘firebase-kotlin-sdk-folder’ directory is? I can’t find it…

Did anyone manage to get this working? I am still encountering the ld: framework not found FirebaseAuth error and I can’t really find the path that @CoreyKaylor is suggesting 😦

i think we are going to need to, most people wont know to add it independently. The error messages are pretty hard to work out that this is the issue.

I have this issue on 1.0.0 @nbransby


> Configure project :core
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
The Kotlin source set androidAndroidTestRelease was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
> Task :core:generateDefNTPKit
> Task :core:podDownload UP-TO-DATE
> Task :core:generateDummyFramework
> Task :core:podspec
> Task :core:podGenIOS
> Task :core:podSetupBuildNTPKitIphonesimulator
> Task :core:podBuildNTPKitIphonesimulator
> Task :core:cinteropNTPKitIos
> Task :core:compileKotlinIos
w: /Users/matanmarciano/projects/***/core/src/commonMain/kotlin/com/***/***/core/utilities/PositionSerializer.kt: (8, 2): This declaration is experimental and its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'
w: /Users/matanmarciano/projects/***/core/src/commonMain/kotlin/com/***/***/core/utilities/RoomStateSerializer.kt: (11, 2): This declaration is experimental and its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'
> Task :core:iosProcessResources NO-SOURCE
> Task :core:iosMainKlibrary
> Task :core:compileTestKotlinIos
> Task :core:linkDebugTestIos
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: framework not found FirebaseDatabase
> Task :core:linkDebugTestIos FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:linkDebugTestIos'.
> Compilation finished with errors
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 13s
10 actionable tasks: 10 executed
16:50:37: Task execution finished 'allTests'.

My main application has !use_frameworks in the Podfile. I’ve added both ‘Firebase/Auth’ and ‘Firebase/Core’ as pod dependencies in the gradle file and it’s able to compile successfully and get loaded from my ios SwiftUI application.