Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Alternative iOS device unique identifier
#import <UIKit/UIKit.h>
@interface UIDevice (HostUUID)
- (NSString *) xcd_uniqueIdentifier;
#import "UIDevice+HostUUID.h"
@implementation UIDevice (HostUUID)
- (NSString *) xcd_uniqueIdentifier
CFUUIDBytes uuidBytes;
gethostuuid((unsigned char *)&uuidBytes, &(const struct timespec){0, 0});
CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, uuidBytes);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuid);
return [CFBridgingRelease(uuidString) lowercaseString];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment