Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个多平台项目,iOS 和 JVM(我不直接针对 Android)。根据构建类型(调试或发布),我想配置日志记录级别(即仅打印发布中的错误)。由于没有BuildConfig可用的类,我如何从commonMain构建类型中知道?
BuildConfig
commonMain
不是对这个问题的直接回答,但对于 android/ios,可以定义如下属性:
共同点主要:
expect val isDebug: Boolean
在 androidMain 中:
actual val isDebug = BuildConfig.DEBUG
在 iosMain 中:
actual val isDebug = Platform.isDebugBinary