Last active
November 3, 2017 16:51
-
-
Save bishalg/e34da533210497ab070923438a477fdb to your computer and use it in GitHub Desktop.
AppInfo Swift - Util to get app infos like build / version number etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppInfo.swift | |
// This is an Util to get app infos like build / version number etc | |
// Swift 3.0 | |
// Xcode 8.0 | |
// | |
import Foundation | |
import AVFoundation | |
class AppInfo { | |
/// Returns DEBUG or RELEASE info with version and build number | |
static func buildInfo() -> String { | |
#if DEBUG | |
return "DEBUG" + versionInfo() | |
#else | |
return "RELEASE" + versionInfo() | |
#endif | |
} | |
/// Returns Version Info - Vesrion Number & Build Number | |
static func versionInfo() -> String { | |
return " v " + self.versionString() + " b " + buildString() | |
} | |
static func versionString() -> String { | |
return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String | |
} | |
static func buildString() -> String { | |
return Bundle.main.infoDictionary?["CFBundleVersion"] as! String | |
} | |
static func appName() -> String { | |
return Bundle.main.infoDictionary?["CFBundleName"] as! String | |
} | |
static func apiVersionNumber() -> String { | |
return Bundle.main.infoDictionary?["API_VERSION"] as! String | |
} | |
static var outputVolume: Float { | |
return AVAudioSession.sharedInstance().outputVolume | |
} | |
static var outputVolDB: Float { | |
return 20.0 * log10f(AppInfo.outputVolume + FLT_MIN) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment