Search code examples
swiftrealmios-app-group

Realm, Configuration and app groups


I'd like to use Realm with app groups to be able to share data with watch extension. I'm facing problem, that when I try to configure default realm.. By that I mean that I create new path and then I create new configuration. So far so good, but when I try to set this configuration as defaultConfiguration, nothing happens. For better idea check screenshot where is my code plus console output. Any idea? Thank you

enter image description here


Solution

  • The defaultConfiguration you set on Realm.Configuration is used to initialize new Realms. So if you would print the path of a Realm instance, e.g. try! Realm().path, then this would reflect the path from the shared app group. You did instead initialize a new & fresh configuration, which always uses the initial default values.