0

I would like to access my Realm from an iOS extension however the realm path is unavailable when using the Realm Mobile Platform. I've received advice from realm to hold a cloned copy and keep it in sync. How can that be achieved? ...and is it considered a "clean" solution? (there could be multiple realms)

gerbil
  • 859
  • 7
  • 26

1 Answers1

1

You should just open the synced Realm from your extension by creating a Realm configuration with a proper sync configuration (specifying user and remote Realm URL), like usual.

This is the only currently supported way to use the same synced Realm with both an app and its associated extension(s). The underlying reason is because Realm's synchronization subsystem doesn't support accessing the same synced Realm file concurrently from multiple processes.

AustinZ
  • 1,787
  • 1
  • 13
  • 21
  • Does it mean the extension would need to first sync the entire db? That could take a long time wouldn't it? – gerbil Jun 27 '17 at 19:32
  • It depends on how big your database is, and you can start reading and writing locally before the synchronization is complete. – AustinZ Jun 27 '17 at 20:48
  • I can't because I need get the data first in order to know the state in the extension is valid. This is not a good solution to the problem (unfortunately) – gerbil Jun 27 '17 at 20:50
  • Feel free to file a ticket on our [GitHub ticket tracker](https://github.com/realm/realm-cocoa/issues) if you want additional functionality. – AustinZ Jun 27 '17 at 20:51