firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

Impossible compile iOS Target Unresolved reference

Open samuele794 opened this issue 3 years ago • 0 comments
trafficstars

At compile time library is not found

Library version: 1.6.1 Platform: Mac M1

> Task :shared:compileIosMainKotlinMetadata FAILED
w: Could not find "org.jetbrains.kotlin.native.platform.linux" in [/Users/abstract/StudioProjects/Scala, /Users/abstract/.konan/klib, /Users/abstract/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.20/klib/common, /Users/abstract/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.20/klib/platform/ios_arm64]
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/KoinIOS.kt: (4, 12): Unresolved reference: gitlive
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/KoinIOS.kt: (5, 12): Unresolved reference: gitlive
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/KoinIOS.kt: (16, 9): Unresolved reference: Firebase
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/viewmodel/auth/NativeAuth.kt: (3, 12): Unresolved reference: gitlive
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/viewmodel/auth/NativeAuth.kt: (10, 37): Unresolved reference: AuthCredential
e: /Users/abstract/StudioProjects/Scala/shared/src/iosMain/kotlin/it/samuele794/scala/viewmodel/auth/NativeAuth.kt: (10, 63): Unresolved reference: AuthCredential

My current gradle for shared source

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    kotlin(Dependencies.Plugins.kotlinSerialization) version Version.kotlinVersion
    id(Dependencies.Plugins.androidLibrary)
    id(Dependencies.Plugins.completeKotlin) version Version.completeKotlinVersion
    id(Dependencies.Plugins.multiplatformResources)
    id(Dependencies.Plugins.buildKonfig)
    id(Dependencies.Plugins.ksp) version Version.kspVersion
    id("kotlin-parcelize")
}

android {
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    compileSdk = libs.versions.compileSdk.get().toInt()
    defaultConfig {
        minSdk = libs.versions.minSdk.get().toInt()
        targetSdk = libs.versions.targetSdk.get().toInt()
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }
    testOptions {
        unitTests {
            isIncludeAndroidResources = true
        }
    }

    lint {
        isWarningsAsErrors = false
        isAbortOnError = false
    }
}

version = "1.2"

android {
    configurations {
        create("androidTestApi")
        create("androidTestDebugApi")
        create("androidTestReleaseApi")
        create("testApi")
        create("testDebugApi")
        create("testReleaseApi")
    }
}

kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    sourceSets {
        all {
            languageSettings.apply {
                optIn("kotlin.RequiresOptIn")
                optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
            }
        }
    }

    // Enable concurrent sweep phase in new native memory manager. (This will be enabled by default in 1.7.0)
    // https://kotlinlang.org/docs/whatsnew1620.html#concurrent-implementation-for-the-sweep-phase-in-new-memory-manager
    targets.withType<KotlinNativeTarget> {
        binaries.all {
            freeCompilerArgs += "-Xgc=cms"
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(Dependencies.Koin.core)
                implementation(Dependencies.Coroutines.core)

                api(Dependencies.kermit)
                api(Dependencies.kermitCrashlytics)

                implementation(Dependencies.serialization)

                with(Dependencies.Ktor) {
                    implementation(core)
                    implementation(cio)
                    implementation(logging)
                    implementation(contentNegotiation)
                    implementation(json)
                }

                with(Dependencies.Moko) {
                    api(resources)
                    api(parcelize)
                }

                api(Dependencies.dateTime)
                implementation(Dependencies.ktorFit)

                // https://github.com/GitLiveApp/firebase-kotlin-sdk
                implementation("dev.gitlive:firebase-firestore:1.6.1")
                implementation("dev.gitlive:firebase-common:1.6.1")
                implementation("dev.gitlive:firebase-auth:1.6.1")
            }
        }
        val commonTest by getting {
            dependencies {
                // implementation(libs.bundles.shared.commonTest)
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(libs.androidx.lifecycle.viewmodel)
                implementation(libs.ktor.client.okHttp)

                implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
                implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")

//                implementation(project.dependencies.platform("com.google.firebase:firebase-bom:29.3.1"))

                // Declare the dependency for the Firebase Authentication library
                // When using the BoM, you don't specify versions in Firebase library dependencies
//                implementation("com.google.firebase:firebase-auth-ktx")

                // Also declare the dependency for the Google Play services library and specify its version
                implementation("com.google.android.gms:play-services-auth:20.1.0")

                // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-play-services
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.1")

                api("dev.icerock.moko:resources-compose:0.19.0")

                api("com.google.android.gms:play-services-maps:18.0.2")

                implementation("com.firebase:geofire-android-common:3.2.0")
            }
        }
        val androidTest by getting {
            dependencies {
                // implementation(libs.bundles.shared.androidTest)
            }
        }
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
    }

    sourceSets.matching { it.name.endsWith("Test") }
        .configureEach {
            languageSettings.optIn("kotlin.time.ExperimentalTime")
        }

    cocoapods {
        summary = "Common library for the KaMP starter kit"
        homepage = "https://github.com/touchlab/KaMPKit"
        framework {
            isStatic = false // SwiftUI preview requires dynamic framework
//            baseName = "shared"
        }
        ios.deploymentTarget = "14.1"
        podfile = project.file("../ios/Podfile")
    }
}

multiplatformResources {
    multiplatformResourcesPackage = "it.samuele794.scala.resources"
    multiplatformResourcesClassName = "SharedRes"
}

buildkonfig {
    packageName = "it.samuele794.scala"

    defaultConfigs {
        buildConfigField(STRING, "GOOGLE_API_BASE_URL", "https://maps.googleapis.com/")
    }
}

samuele794 avatar Jun 23 '22 09:06 samuele794