Skip to content

Commit 82f12fe

Browse files
committed
Simplify
1 parent a696462 commit 82f12fe

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

Sources/SentryDistribution/Mach-O/BinaryParser.swift

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ import MachO
55
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)
66

77
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
138

14-
static func getMainBinaryUUID() -> String {
9+
static func getMainBinaryUUID() -> String? {
1510
guard let executableName = Bundle.main.infoDictionary?["CFBundleExecutable"] as? String else {
16-
fatalError("Executable name not found.")
11+
return nil
1712
}
1813
let executablePath = "\(Bundle.main.bundlePath)/\(executableName)"
1914

@@ -25,18 +20,12 @@ struct BinaryParser {
2520
continue
2621
}
2722

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)
2924
let _ = withUnsafeMutablePointer(to: &_uuid) {
3025
_dyld_get_image_uuid(header, $0)
3126
}
32-
return formatUUID(_uuid)
27+
return UUID(uuid: _uuid).uuidString
3328
}
34-
return ""
35-
}
36-
}
37-
38-
private extension UInt8 {
39-
var asHex: String {
40-
String(format: "%02X", self)
29+
return nil
4130
}
4231
}

0 commit comments

Comments
 (0)