@@ -13,18 +13,16 @@ class BuildDetails {
13
13
static var `default` = BuildDetails ( )
14
14
15
15
let dict : [ String : Any ]
16
- private var cachedProfileExpirationDate : Date ?
17
16
18
17
init ( ) {
19
18
guard let url = Bundle . main. url ( forResource: " BuildDetails " , withExtension: " .plist " ) ,
20
- let data = try ? Data ( contentsOf: url) ,
21
- let parsed = try ? PropertyListSerialization . propertyList ( from: data, format: nil ) as? [ String : Any ] else
19
+ let data = try ? Data ( contentsOf: url) ,
20
+ let parsed = try ? PropertyListSerialization . propertyList ( from: data, format: nil ) as? [ String : Any ] else
22
21
{
23
22
dict = [ : ]
24
23
return
25
24
}
26
25
dict = parsed
27
- cachedProfileExpirationDate = loadProfileExpirationDate ( )
28
26
}
29
27
30
28
var buildDateString : String ? {
@@ -48,11 +46,11 @@ class BuildDetails {
48
46
}
49
47
50
48
var profileExpiration : Date ? {
51
- return cachedProfileExpirationDate
49
+ return dict [ " com-loopkit-Loop-profile-expiration " ] as? Date
52
50
}
53
51
54
52
var profileExpirationString : String {
55
- if let profileExpiration = cachedProfileExpirationDate {
53
+ if let profileExpiration = profileExpiration {
56
54
return " \( profileExpiration) "
57
55
} else {
58
56
return " N/A "
@@ -65,41 +63,7 @@ class BuildDetails {
65
63
}
66
64
67
65
var workspaceGitBranch : String ? {
68
- return dict [ " com-loopkit-LoopWorkspace-git-branch " ] as? String
69
- }
70
-
71
- private func loadProfileExpirationDate( ) -> Date ? {
72
- guard
73
- let profilePath = Bundle . main. path ( forResource: " embedded " , ofType: " mobileprovision " ) ,
74
- let profileData = try ? Data ( contentsOf: URL ( fileURLWithPath: profilePath) ) ,
75
- let profileNSString = NSString ( data: profileData, encoding: String . Encoding. ascii. rawValue)
76
- else {
77
- print (
78
- " WARNING: Could not find or read `embedded.mobileprovision`. If running on Simulator, there are no provisioning profiles. "
79
- )
80
- return nil
81
- }
82
-
83
- let regexPattern = " <key>ExpirationDate</key>[ \\ W]*?<date>(.*?)</date> "
84
- guard let regex = try ? NSRegularExpression ( pattern: regexPattern, options: [ ] ) ,
85
- let match = regex. firstMatch (
86
- in: profileNSString as String ,
87
- options: [ ] ,
88
- range: NSRange ( location: 0 , length: profileNSString. length)
89
- ) ,
90
- let range = Range ( match. range ( at: 1 ) , in: profileNSString as String )
91
- else {
92
- print ( " Warning: Could not create regex or find match. " )
93
- return nil
94
- }
95
-
96
- let dateString = String ( profileNSString. substring ( with: NSRange ( range, in: profileNSString as String ) ) )
97
- let dateFormatter = DateFormatter ( )
98
- dateFormatter. dateFormat = " yyyy-MM-dd'T'HH:mm:ss'Z' "
99
- dateFormatter. locale = Locale ( identifier: " en_US_POSIX " )
100
- dateFormatter. timeZone = TimeZone ( secondsFromGMT: 0 )
101
-
102
- return dateFormatter. date ( from: dateString)
66
+ return dict [ " com-loopkit-LoopWorkspace-git-branch " ] as? String
103
67
}
104
68
}
105
69
0 commit comments