I added the below setting to my project and the preview could be show in Xcode.
kotlin {
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
isStatic = false
}
}
}
This thread in github helped me.
https://github.com/JetBrains/kotlin-native/issues/3059#issuecomment-577041551