Skip to content

Instantly share code, notes, and snippets.

@christianascone
Last active June 21, 2017 08:38
Show Gist options
  • Save christianascone/7d9cee7c0d79738fac172048492ea0aa to your computer and use it in GitHub Desktop.
Save christianascone/7d9cee7c0d79738fac172048492ea0aa to your computer and use it in GitHub Desktop.
Version Utils class for finding info about app version and build number
//
// VersionUtils.swift
//
// Created by Christian Ascone on 21/06/2017.
// Copyright © 2017 Christian Ascone. All rights reserved.
//
import Foundation
class VersionUtils {
/// If found in infoDictionary, returns the app version
static func getVersion() -> String {
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
return version
}
return ""
}
/// If found in infoDictionary, returns the build number
static func getBuildNumber() -> String {
if let version = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
return version
}
return ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment