Hey guys. I want to find application version code in Kmm. In specific platform i.e. Android ```var v...
v
Hey guys. I want to find application version code in Kmm. In specific platform i.e. Android
Copy code
var versionCode = BuildConfig.VERSION_CODE
it will return
1.1
iOS
Copy code
let appVersion = "iOS " + (Bundle.main.versionNumber ?? "")
it will return
1.1
The above code is for native. What code should I use in KMM?
h
Use
expect/actual
v
@hfhbd @jw I'll use expect/actual but what code will give me version code ?
j
The one that you write yourself and map to those APIs on each platform
v
Okk I'll try that
h
Keep in mind for iOS you need Objective-C api
Written in Kotlin
v
Can you give me reference please?
val mainBundle = platform.Foundation.NSBundle.mainBundle.infoDictionary?.get("CFBundleVersion")
v
great thanks
165 Views