I have create a TestKotinNative app, but only work when run on simulator.
When I run on my device (iphone 7, 13.4.1), xcode show error "TestKotlinNative.xcodeproj Building for iOS, but the linked and embedded framework 'SharedCode.framework' was built for iOS Simulator."
My Xcode version: 11.4.1
Please help me! Thank

Hello, @lehanphong!
First of all, I got to remind you that Kotlin/Native issue tracker is in the process of migration onto the YouTrack(#4079).
So, if you want to report a bug or propose a feature - please use this link - https://kotl.in/issue. For usage-related questions - please ask on StackOverflow with kotlin-native tag: https://stackoverflow.com/questions/ask?tags=kotlin-native. For community discussions - use #kotlin-native and #multiplatform channels in Slack workspace for Kotlin community -- https://slack.kotl.in.
About this particular question - this one seems like an incorrect build configuration, rather than a bug. Please share your Gradle script contents so anything more specific can be said. Check if there is an iosArm32 or iosArm64 target in it - those are for targeting a device. If there is only iosX64, this behavior can be assumed as expectable.
@artdfel This is my build.gradle.kts (same with https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/06_SettingUpKotlinFramework)
plugins {
kotlin("multiplatform")
}
kotlin {
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "SharedCode"
}
}
}
jvm("android")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
}
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText("#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n")
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
Okay then, I'm closing this one as a duplicate. I also found you posted the question to the StackOverflow and answered there, please check if my advice helps.