https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

sushma nayak

04/07/2021, 10:24 PM
Hi all! I'm. getting a linker error when running the iOS app through Xcode. The app is building and running without error on Android studio though and running through device too. Error:
Copy code
ld: warning: ignoring file ****/common/build/cocoapods/framework/common.framework/common, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
Undefined symbols for architecture arm64:
 "_OBJC_CLASS_$_CommonSafeStore", referenced from:
      objc-class-ref in AppCoordinator.o
ld: symbol(s) not found for architecture arm64
SafeStore
is an
expect/actual class
. After adding this the issue arose. Is there anything additional that is needed for expect/actual declared classes to run on Xcode?
i

itnoles

04/08/2021, 1:52 AM
"building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64"
s

sushma nayak

04/08/2021, 9:10 AM
Any idea how to fix it?
I created a new sample KMM project with cocoapods as default integrator. I tries running the ios project through Xcode. Even that is failing with
building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
I'm on M1 mac.
m

Mustafa Ozhan

04/08/2021, 2:54 PM
can you share your build.gradle (from, shared module)
s

sushma nayak

04/08/2021, 5:42 PM
Copy code
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
}

version = "1.0"

kotlin {
    android()

    val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64

    iosTarget("ios") {}

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        frameworkName = "shared"
        podfile = project.file("../iosApp/Podfile")
    }
    
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13.2")
            }
        }
        val iosMain by getting
        val iosTest by getting
    }
}

android {
    compileSdkVersion(30)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(21)
        targetSdkVersion(30)
    }
}
@Mustafa Ozhan
y

Yashar

04/11/2021, 4:55 PM
Have you excluded
arm64
? Doing that solved a lot of headaches for me when working on M1 machine.
17 Views