#if os(macOS) import Foundation import MachO /// Information about this executable. public enum ExecutableInfo { /// A stable identifier for this executable. Uses the Mach-O header UUID on macOS. Nil on Linux. public static let buildID: String? = { if let handle = dlopen(nil, RTLD_LAZY) { defer { dlclose(handle) } if let ptr = dlsym(handle, MH_EXECUTE_SYM) { return getUUID(pointer: ptr)?.uuidString } } return nil }() private static func getUUID(pointer: UnsafeRawPointer) -> UUID? { var offset: UInt64 = 0 let header = pointer.bindMemory(to: mach_header_64.self, capacity: 1) offset += UInt64(MemoryLayout.size) for _ in 0..