Hi!
We are using some graphics components in our KMM project, those graphics components uses Metal but since it is not available in the simulator, I need to have OpenGL classes for those same components.
I’m doing it by having different implementations for iosArm64 and iosX64 targets, however, I’m not sure which is the best approach to configure this on gradle.
If I use the typical
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
System.getenv("NATIVE_ARCH")?.startsWith("arm") == true -> ::iosSimulatorArm64
else -> ::iosX64
}
iosTarget("ios") {}
Then the code for both arm64 and X64 is not built so compilation fails
I got a suggestion about adding
val isIdeaSyncing = System.getProperty("idea.sync.active") != null
if (isIdeaSyncing) {
iosX64("ios")
} else {
ios()
iosX64()
iosArm64()
}
Which works, but Android Studio is complaining and code completion is not working in both arm64 and X64 files.
Question is which is the best way to have different code for both simulator and device.
Thanks!