RealmBrowser-iOS
RealmBrowser-iOS copied to clipboard
Realm placed in an App Group won't show contents.
My Realm is stored in an app group. When I load RLMBrowserViewController it will show me the correct models and the number of entries they have, but when I open a model it will show me an empty tableview.
When I place the Realm locally in the app, everything works fine.
Ah, sorry @Sjoerdjanssenen! I haven't fully finished documenting it yet.
There's provisions for Realm files in app groups. But unfortunately there's no way to store the absolute file path URL to them (Because they dynamically change each time the app is launched), so they have to be manually registered before the Browser has enough information to generate the URL.
If you do this before you present the browser view controller, it SHOULD work.
[RLMBrowserViewController registerAppGroupRealmAtRelativePath:@"TodayWidget/TodayWidget.realm"
forGroupIdentifier:@"group.timoliver.icomics"];
Let me know how you go!
Aah, thanks for the reply. So just to get this clear for me, this would mean I'd have to run that before initialising the RLMBrowserViewController?
[RLMBrowserViewController registerAppGroupRealmAtRelativePath:@"db.realm"
forGroupIdentifier:@"group.myorganisation.myapp"];
RLMBrowserViewController *controller = [[RLMBrowserViewController alloc] init];
[self presentViewController:controller animated:YES completion:nil];
Sorry for the delay!
Yep! As long as your Realm file is in the root directory of your app group, that SHOULD work as it is.
Let me know if it doesn’t. :)
Thanks for the reply. It won't work for me with this code, though.
In my application, there's a Utilities class that contains the following methods:
+ (NSString *)getRealmPath {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *storeUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:@"group.myorganisation.myapp"];
NSString *path = [storeUrl path];
path = [path stringByAppendingPathComponent:@"db.realm"];
return path;
}
+ (RLMRealm *)getRealm {
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.fileURL = [NSURL URLWithString:[self getRealmPath]];
return [RLMRealm realmWithConfiguration:config error:nil];
}
And I present RLMBrowserViewController with the code I posted before:
[RLMBrowserViewController registerAppGroupRealmAtRelativePath:@"db.realm"
forGroupIdentifier:@"group.myorganisation.myapp"];
RLMBrowserViewController *controller = [[RLMBrowserViewController alloc] init];
[self presentViewController:controller animated:YES completion:nil];
It won't show it's contents, though.
Hmmm. Is it appearing in the Browser and you can tap on it at least?
Yeah, I can see the Realm file and the models, but not the entries.
If that's the case, it sounds like the Realm property metadata isn't getting captured properly. Hmm, I'm not sure how I can debug that. :(