Straight from the Kotlin Multiplatform for iOS and Android tutorial I have a template source file for iOS code which looks like this:
class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()
Now I would like to change the value of the name
override using iOS #if/#else/#endif
code mechanism. In typical kotlin fashion I would write something like this for the android platform:
class IOSPlatform : Platform {
override val name: String
get() {
if (BuildConfig.DEBUG) {
return UIDevice.currentDevice.systemName() + " debug " + UIDevice.currentDevice.systemVersion
} else {
return UIDevice.currentDevice.systemName() + " release " + UIDevice.currentDevice.systemVersion
}
}
}
However, there is no BuildConfig
equivalent for iOS, and obviously I can't write #if DEBUG
in Kotlin like I would in Swift. Is my only option to call a custom Swift implementation where the #if
conditional is implemented in a .swift
source file?