https://kotlinlang.org logo
Title
a

Anshulupadhyay03

05/14/2023, 5:29 PM
Hi Guys...I am new to the kmm world and trying to learn kmm. I am trying to run/build my first compose Android+ ios app using kmm. However, i am getting strange errors when i run the ios app. The Android app works fine. I have not added any compose-related code in the iosApp as I wanted to check if everything works fine after adding compose-related dependencies in commonMain. The strange thing is that this error goes away when I comment the compose-related dependency in common main section of the gradle file. I am able to run ios app for other compose-multiplatform tutorial apps. Can anyone point the issue? gradle file
plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("org.jetbrains.compose")
}

kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
        }
    }
    
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(compose.runtime)
                implementation(compose.foundation)
                implementation(compose.material)
                implementation(compose.ui)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                // Android
                api(libs.androidx.activity.compose)
                api(libs.androidx.appcompat)
                api(libs.androidx.core.ktx)

                // Ktor
                api(libs.ktor.client.okhttp)
            }
        }
        val androidUnitTest by getting
        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)
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
}
the error i am getting is
"_kCTFontWidthTrait", referenced from:
      create_descriptor(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontDescriptorGetSkFontStyle(__CTFontDescriptor const*, bool) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
ld: symbol(s) not found for architecture arm64

> Task :shared:linkPodDebugFrameworkIosSimulatorArm64 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:linkPodDebugFrameworkIosSimulatorArm64'.
> Compilation finished with errors
j

Jan

05/14/2023, 5:59 PM
Make your Cocoapods Framework static See Compose-Multiplattform-templates: framework{ baseName=… isStatic=true }
a

Anshulupadhyay03

05/14/2023, 6:29 PM
@Jan Great! thank you for this. It worked now. Can u explain what does it do?
a

Anshulupadhyay03

05/14/2023, 8:49 PM
@Jan thanks for the help. I am facing some other issue...do u know what is this now.
j

Jan

05/15/2023, 8:31 AM
@Anshulupadhyay03 not really. I guess your App is a Composable?
a

Anshulupadhyay03

05/15/2023, 8:55 AM
@Jan Yes , compose multiplatform.