2

From within my Kotlin-Native shared code I need to get the build variant of the app running it - for both Android and iOS.

Is it possible and how can I get it?

Assuming in commonMain I'll have expect val buildVar: String, then how would I get the respective build variants within the androidMain and iosMain main directories? actual val buildVar = ...???

5
  • Seems like you can do something like this in Android part, and like that for iOS. Commented Jan 15, 2020 at 13:43
  • @ArtyomDegtyarev thanks, but those work natively - I'm looking to do it via kotlin-native. I'm not sure if it is possible, but hoping someone has an answer out there. Like something similar to import platform.UIKit.UIDevice actual fun platformName(): String { return UIDevice.currentDevice.systemVersion } to get the iOS device's system version. Commented Jan 15, 2020 at 14:27
  • 1
    I think you can import platform.Foundation.NSBundle and go with a solution above. About android - in the question it is unclear are you targeting android() or androidNativeArm32/64. For just android(), the first link seems totally applicable. Commented Jan 15, 2020 at 14:44
  • Thanks! - for iOS that was helpful. Got an implementation which in theory seems to work, but will post a solution when I get a chance to run it properly. I'm targeting android() but not having any success in trying to access the buildConfig from Kotlin-Native. Commented Jan 16, 2020 at 8:54
  • 1
    See also:github.com/yshrsmz/BuildKonfig Commented Jan 16, 2020 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.