https://kotlinlang.org logo
Title
v

Vivek Modi

04/14/2022, 11:14 PM
Hey guys how can I get application version code in iosMain in KMM ? I asked my ios team they provide me some code which is working in iOS side
let appVersion = “iOS ” + (Bundle.main.versionNumber ?? “”)
But I don't understand how to use this in iosMain in kmm. Is any other code ?
r

ribesg

04/15/2022, 8:12 AM
When working with Kotlin on iOS, you’re basically writting Objective-C in Kotlin, not Swift in Kotlin. Next time ask them for Objective-C code, this way you can translate it more easily. This time they would have probably answered with something that, written in Kotlin, would look like this:
NSBundle.mainBundle.infoDictionary?.get("CFBundleShortVersionString") as String?
v

Vivek Modi

04/15/2022, 8:15 AM
@ribesg great thanks a million. I'll remember your suggestion for next time. ✌️
👍 1