Find out version/build statically

Assume bundle and info dictionary are never nil.
This commit is contained in:
Davide De Rosa 2018-10-18 13:57:56 +02:00
parent fdb8762814
commit 567ddd9b12
3 changed files with 7 additions and 14 deletions

View File

@ -27,9 +27,7 @@ import TunnelKit
class PacketTunnelProvider: TunnelKitProvider {
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
if let version = GroupConstants.App.version {
appVersion = "\(GroupConstants.App.name) \(version)"
}
appVersion = "\(GroupConstants.App.name) \(GroupConstants.App.versionString)"
dnsTimeout = GroupConstants.VPN.dnsTimeout
logSeparator = GroupConstants.VPN.sessionMarker
super.startTunnel(options: options, completionHandler: completionHandler)

View File

@ -34,14 +34,11 @@ class GroupConstants {
static let title = name
// static let title = "\u{1F511}"
static var version: String? {
guard let info = Bundle.main.infoDictionary else {
return nil
}
let versionNumber = info["CFBundleShortVersionString"] as! String
let buildNumber = info[kCFBundleVersionKey as String] as! String
return "\(versionNumber) (\(buildNumber))"
}
static let versionNumber = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
static let buildNumber = Int(Bundle.main.infoDictionary![kCFBundleVersionKey as String] as! String)!
static let versionString = "\(versionNumber) (\(buildNumber))"
static let teamId = "5357M5NW9W"

View File

@ -46,10 +46,8 @@ struct DebugLog {
}
func decoratedString() -> String {
guard let appVersion = GroupConstants.App.version else {
fatalError("Could not find bundle app version?")
}
let appName = GroupConstants.App.name
let appVersion = GroupConstants.App.versionString
var metadata: [String] = []
let osVersion: String