Hello. I'm struggling to find a solution for a problem that seems simple.
I鈥檓 working on a multiplaform project, iOS and JVM (I鈥檓 not targeting Android directly) and depending on the build type (debug or release) I want to configure the logging level (i.e. to print only errors in release). Since there is no a _BuildConfig_ class available (like the one generated by the Android gradle plugin), how can I know from commonMain the build type?
Hello.
You can configure debug and release binaries to include alternative source sets.
See the example here: https://github.com/ilmat192/kotlin-native-gradle-samples/tree/master/debug-logger
Debug builds include commonDebug source set, release builds include commonRelease instead.
Seems like a lot of gradle work to just carry separate source sets. Can we define a constant similar (a la BuildConfig.DEBUG) that is derived from the project build property in the build?
When using isDebugBinary will the code get removed completely if isDebugBinary is false in this example:
if (Platform.isDebugBinary) {
println("hello")
}
Will the println function get optimised away just as if isDebugBinary would be a false constant in the JVM?
It should. Please report an issue if you discover that it doesn't.
Most helpful comment
Seems like a lot of gradle work to just carry separate source sets. Can we define a constant similar (a la BuildConfig.DEBUG) that is derived from the project build property in the build?