Instantly share code, notes, and snippets.

What would you like to do?
Swift: get the Mac UUID
func getSystemUUID() -> String? {
let dev = IOServiceMatching("IOPlatformExpertDevice")
let platformExpert: io_service_t = IOServiceGetMatchingService(kIOMasterPortDefault, dev)
let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformUUIDKey, kCFAllocatorDefault, 0)
let ser: CFTypeRef = serialNumberAsCFString.takeUnretainedValue()
if let result = ser as? String {
return result
return nil
if let uuid = getSystemUUID() {

This comment has been minimized.

Copy link

SLboat commented Jun 26, 2016

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment