@@ -5,15 +5,10 @@ import MachO
5
5
fileprivate let _dyld_get_image_uuid = unsafeBitCast ( dlsym ( dlopen ( nil , RTLD_LAZY) , " _dyld_get_image_uuid " ) , to: ( @convention( c) ( UnsafePointer < mach_header > , UnsafeRawPointer) - > Bool) . self)
6
6
7
7
struct BinaryParser {
8
- //swiftlint:disable large_tuple
9
- private static func formatUUID( _ uuid: ( UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 ) ) -> String {
10
- " \( uuid. 0 . asHex) \( uuid. 1 . asHex) \( uuid. 2 . asHex) \( uuid. 3 . asHex) - \( uuid. 4 . asHex) \( uuid. 5 . asHex) - \( uuid. 6 . asHex) \( uuid. 7 . asHex) - \( uuid. 8 . asHex) \( uuid. 9 . asHex) - \( uuid. 10 . asHex) \( uuid. 11 . asHex) \( uuid. 12 . asHex) \( uuid. 13 . asHex) \( uuid. 14 . asHex) \( uuid. 15 . asHex) "
11
- }
12
- //swiftlint:enable large_tuple
13
8
14
- static func getMainBinaryUUID( ) -> String {
9
+ static func getMainBinaryUUID( ) -> String ? {
15
10
guard let executableName = Bundle . main. infoDictionary ? [ " CFBundleExecutable " ] as? String else {
16
- fatalError ( " Executable name not found. " )
11
+ return nil
17
12
}
18
13
let executablePath = " \( Bundle . main. bundlePath) / \( executableName) "
19
14
@@ -25,18 +20,12 @@ struct BinaryParser {
25
20
continue
26
21
}
27
22
28
- var _uuid = UUID ( ) . uuid
23
+ var _uuid : uuid_t = ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
29
24
let _ = withUnsafeMutablePointer ( to: & _uuid) {
30
25
_dyld_get_image_uuid ( header, $0)
31
26
}
32
- return formatUUID ( _uuid)
27
+ return UUID ( uuid : _uuid) . uuidString
33
28
}
34
- return " "
35
- }
36
- }
37
-
38
- private extension UInt8 {
39
- var asHex : String {
40
- String ( format: " %02X " , self )
29
+ return nil
41
30
}
42
31
}
0 commit comments