@@ -13,7 +13,6 @@ class BuildDetails {
1313 static var `default` = BuildDetails ( )
1414
1515 let dict : [ String : Any ]
16- private var cachedProfileExpirationDate : Date ?
1716
1817 init ( ) {
1918 guard let url = Bundle . main. url ( forResource: " BuildDetails " , withExtension: " .plist " ) ,
@@ -24,7 +23,6 @@ class BuildDetails {
2423 return
2524 }
2625 dict = parsed
27- cachedProfileExpirationDate = loadProfileExpirationDate ( )
2826 }
2927
3028 var buildDateString : String ? {
@@ -48,11 +46,11 @@ class BuildDetails {
4846 }
4947
5048 var profileExpiration : Date ? {
51- return cachedProfileExpirationDate
49+ return dict [ " com-loopkit-Loop-profile-expiration " ] as? Date
5250 }
5351
5452 var profileExpirationString : String {
55- if let profileExpiration = cachedProfileExpirationDate {
53+ if let profileExpiration = profileExpiration {
5654 return " \( profileExpiration) "
5755 } else {
5856 return " N/A "
@@ -65,41 +63,7 @@ class BuildDetails {
6563 }
6664
6765 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
10367 }
10468}
10569
0 commit comments