KeyedArchiverUID in Swift

Can this be done in Swift without a cHelper?


@import Foundation;
CFTypeID keyedArchiverUIDTypeId(void);


id _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value);

CFTypeID keyedArchiverUIDTypeId(void)
	id keyedArchiverUID =  _CFKeyedArchiverUIDCreate(kCFAllocatorDefault, 43);
	return CFGetTypeID( CFBridgingRetain(keyedArchiverUID) );

That is, is there some (visible to Swift) Definition of the TypeID of a CFKeyedArchiverUID?

Second, a related question: Can this be done in Swift without a cHelper:

uint32_t _CFKeyedArchiverUIDGetValue(id raw);

uint32_t keyedArchiverValue(id raw)
	return _CFKeyedArchiverUIDGetValue(raw);

Kind regards,


Out of curiosity, what are you doing with keyed archiver UIDs? The keyed archiver UID type is private and not meant to be accessed outside of Foundation and CoreFoundation (nor would it generally provide much benefit); I'm curious if this is an XY problem.

1 Like

When I try to open some older nib files, Xcode (Version 12.4 (12D4e)) offers to convert them to a newer format.
But then it fails with:
Tried to create a document (class: IBXIBDocument) and got a document with a different, non-conforming fileType back instead.

Xcode 10.1 can convert these old .nibs just fine. But Xcode 10.1 refuses to run on Apple Silicon.

So I am trying to convert a keyedobjects.nib into a designable.nib.

This means that I need to parse keyedobjects.nib which contains lots of keyed archiver UIDs.

Maybe someone knows of a better way to do this - this would be very welcome indeed.

Kind regards,


There are Python libraries that can read binary plists and object archives. I’ve used bpylist, which I forked to add few things that I was missing for my project.

I’m not necessarily ready to recommend this as an optimal approach, but worth to consider.

you can use private attribute @_silgen_name for c function declaration.

func _CFKeyedArchiverUIDCreate(allocator: CFAllocator?, value: UInt32) -> Unmanaged<CFTypeRef>

let typeID = CFGetTypeID(_CFKeyedArchiverUIDCreate(allocator: nil, value: 43).takeRetainedValue())
// 41
Terms of Service

Privacy Policy

Cookie Policy