Search code examples
xcodekotlin-multiplatform

Archive KMM app, KotlinClass not in scope


so I have a KMM app over at https://github.com/WhiteWhiskyWolf/all_you

I can't seem to archive the app. When I build through Xcode build for the device, it works. However, if I try and archive the app, either through XCode of Fastlane, every single kotlin class comes back with X not in scope

The Gradle build task is successful when looking at the build logs, so I'm a little lost as to why it's doing that.

So I've added

framework {
            // Required properties
            // Framework name configuration. Use this property instead of deprecated 'frameworkName'
            baseName = "shared"

            // Optional properties
            // Specify the framework linking type. It's dynamic by default.
            isStatic = false
            // Dependency export
            export(project(":shared"))
            transitiveExport = false // This is default.
            // Bitcode embedding
            embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.BITCODE)
        }

        // Maps custom Xcode configuration to NativeBuildType
        xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
        xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE 

And compile against my iosApp target instead of shared, and now I'm getting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:linkPodReleaseFrameworkIosArm64'.
> java.lang.StackOverflowError (no error message) 

EDIT:

Adding my depencies

sourceSets {
        val commonMain by getting {
            dependencies {
                api("io.insert-koin:koin-core:${Koin.version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${KotlinVersions.coroutines}")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${KotlinVersions.serialization}")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:${KotlinVersions.date}")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation("io.mockative:mockative:${Mockk.version}")
                api("io.insert-koin:koin-test:${Koin.version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KotlinVersions.coroutines}")
                implementation("app.cash.turbine:turbine:${Turbine.version}")
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.gms:google-services:${Android.googleService}")
                implementation("com.google.android.gms:play-services-auth:${Firebase.playServiesVersion}")
                implementation("io.insert-koin:koin-android:${Koin.version}")
                implementation(project.dependencies.platform("com.google.firebase:firebase-bom:${Firebase.firebaseBom}"))
                implementation("com.google.firebase:firebase-auth-ktx")
                implementation("com.google.firebase:firebase-firestore-ktx")
                implementation("com.google.firebase:firebase-storage-ktx")
                implementation("com.google.firebase:firebase-messaging-ktx")
            }
        }
        val androidUnitTest by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    } 

Solution

  • So the answer was the project was first set up for "regular framework" but I was using "cocoapods" in the gradle. So the answer was actually to remove the build phase compiling kotlin and it started working. Specififically

    ./gradlew :shared:embedAndSignAppleFrameworkForXcode