I am trying to set the default Realm path to App Groups directory.
let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("groups.prasanna.appName")!
RLMRealm.setDefaultRealmPath(directory.absoluteString!)
println(RLMRealm.defaultRealmPath())
The app crashes with the following error
Terminating app due to uncaught exception 'RLMException', reason: 'open() failed: Operation not permitted'
How do I fix this issue?
the default realm path you're setting is your container directory. You'll have to append a file name for this to work:
let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("groups.prasanna.appName")!
let realmPath = directory.path!.stringByAppendingPathComponent("db.realm")
RLMRealm.setDefaultRealmPath(realmPath)
println(RLMRealm.defaultRealmPath()) // should be realmPath
RLMRealm.setDefaultRealmPath() removed at 0.97 version, you should use this : Tim answer
var config = RLMRealmConfiguration.defaultConfiguration()
config.path = realmPath
RLMRealmConfiguration.setDefaultConfiguration(config)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With