-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathBuildDetails.swift
69 lines (54 loc) · 1.7 KB
/
BuildDetails.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// BuildDetails.swift
// Loop
//
// Created by Pete Schwamb on 6/13/23.
// Copyright © 2023 LoopKit Authors. All rights reserved.
//
import Foundation
class BuildDetails {
static var `default` = BuildDetails()
let dict: [String: Any]
init() {
guard let url = Bundle.main.url(forResource: "BuildDetails", withExtension: ".plist"),
let data = try? Data(contentsOf: url),
let parsed = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any] else
{
dict = [:]
return
}
dict = parsed
}
var buildDateString: String? {
return dict["com-loopkit-Loop-build-date"] as? String
}
var xcodeVersion: String? {
return dict["com-loopkit-Loop-xcode-version"] as? String
}
var gitRevision: String? {
return dict["com-loopkit-Loop-git-revision"] as? String
}
var gitBranch: String? {
return dict["com-loopkit-Loop-git-branch"] as? String
}
var sourceRoot: String? {
return dict["com-loopkit-Loop-srcroot"] as? String
}
var profileExpiration: Date? {
return dict["com-loopkit-Loop-profile-expiration"] as? Date
}
var profileExpirationString: String {
if let profileExpiration = profileExpiration {
return "\(profileExpiration)"
} else {
return "N/A"
}
}
// These strings are only configured if it is a workspace build
var workspaceGitRevision: String? {
return dict["com-loopkit-LoopWorkspace-git-revision"] as? String
}
var workspaceGitBranch: String? {
return dict["com-loopkit-LoopWorkspace-git-branch"] as? String
}
}