Skip to content

Instantly share code, notes, and snippets.

@nixta
Created September 2, 2020 16:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixta/d5407996b24ab5749413bcd33fc6f326 to your computer and use it in GitHub Desktop.
Save nixta/d5407996b24ab5749413bcd33fc6f326 to your computer and use it in GitHub Desktop.
Read and output ArcGIS Runtime SDK version text.
extension Bundle {
private static let agsBundle = AGSBundle()
/// An end-user printable string representation of the ArcGIS Bundle version shipped with the app.
///
/// For example, "2883"
static var sdkBundleVersion: String {
return (agsBundle?.object(forInfoDictionaryKey: "CFBundleVersion") as? String) ?? "?"
}
/// An end-user printable string representation of the ArcGIS Runtime SDK version shipped with the app.
///
/// For example, "100.9.0"
static var sdkVersion: String {
return (agsBundle?.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String) ?? "?"
}
/// Builds an end-user printable string representation of the ArcGIS Bundle shipped with the app.
///
/// For example, "ArcGIS Runtime SDK 100.9.0 (2883)"
static var ArcGISSDKVersionString: String {
return String(format: "ArcGIS Runtime SDK %@ (%@)", sdkVersion, sdkBundleVersion)
}
}
print("\(Bundle.ArcGISSDKVersionString)")
// Outputs, for example:
// ArcGIS Runtime SDK 100.7.0 (2632)
@yo1995
Copy link

yo1995 commented Oct 5, 2021

An addition to the above snippet, to print out the build number on a breakpoint in lldb

(lldb) expression print(AGSBundle().object(forInfoDictionaryKey: "CFBundleVersion") as? String)
// Optional("3289")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment