Getting version information in SWIFT
Often you need to extract version and build information, e.g. to display in an info-box. This short code snippet extracts this information for you and sets an appropriate label.
// Get version info and set version label let dictionary = Bundle.main.infoDictionary! let version = dictionary["CFBundleShortVersionString"] as! String let build = dictionary["CFBundleVersion"] as! String self.versionLabel.text = "Version \(version) Build \(build)"
Leave a comment