Unable to index UUID property on Realm Cocoa 10.20

Hi there,

I have noticed that I make a lot of reads on a UUID field. I decided to put an index on that property:

@Persisted(indexed: true)

The problem is it won’t compile:

(14, 6) Referencing initializer ‘init(indexed:)’ on ‘Persisted’ requires that ‘UUID._RealmValue’ (aka ‘UUID’) conform to ‘_Indexable’

According to the documentation, " Realm supports indexing for string, integer, boolean, Date , UUID , ObjectId , and AnyRealmValue properties.". New in version 10.8.0 : UUID

I’m using the Realm cocoa version: 10.20, so it should work, right?

Hi @Andrei_Matei,

Thank you for spotting this: yes, that’s wrong, and we’ve filed an internal ticket to have this corrected!

1 Like

Cool, thanks.

Any workaround, or ETA?

There’s always the option of converting the UUID to a string (UUID().string) or use an ObjectId instead?

The Realm Cocoa SDK is open source, the internal ticket will be likely linked to a GitHub issue, so you may want to follow that.

UPDATE
GitHub issue

1 Like

@Andrei_Matei A PR has been merged with the fix, you will see it on the next cocoa release.

1 Like

Thank you for the fast response!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.