Closed larson-carter closed 2 days ago
We do not support bundle info dictionaries, as the Info.plist
file won't be installed with your Android app.
So to get the current version number for the app on Android, you can do something like this:
let appVersion: String? = {
#if !SKIP
return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
#else
let context = ProcessInfo.processInfo.androidContext
let packageManager = context.getPackageManager()
let packageInfo = packageManager.getPackageInfo(context.getPackageName(), android.content.pm.PackageManager.GET_META_DATA)
let versionName = packageInfo.versionName
let versionCode = packageInfo.versionCode
return versionName
#endif
}()
I've implemented a synthesized Bundle.main.infoDictionary
with commonly-used keys like CFBundleShortVersionString
and CFBundleIdentifier
in https://github.com/skiptools/skip-foundation/pull/27. You can get it by updating to skip-foundation 1.1.8.
The infoDictionary deriving from the Main Bundle package in Swift's Foundational Package is not available in Skip Yet.
Code example: