realm-swift: Default realm location breaks Apple review rules

Goals

Pass the Apple review with an App using Realm.io

Expected Results

Review failed.

Your app has the UIFileSharingEnabled key set to true in the info.plist, but the Documents folder includes files and folders not intended for file sharing.

The thing I’m seeing is:

image

So I guess they don’t like it. While it’s nice to have this for debugging and maybe exporting to you Mac and looking through the database with an external tool, I think the default should be safe for the Apple Store submission.

Actual Results

Maybe we should make a default location be somewhere else, since I suspect more people may forget to change the location.

Steps to Reproduce

Just enable file sharing with iTunes by setting UIFileSharingEnabled and you’ll see the problem.

Code Sample

.

Version of Realm and Tooling

In the CONTRIBUTING guidelines, you will find a script, which will help determining these versions.

Realm version: Realm 1.0.2

Xcode version: Xcode 8

iOS/OSX version: iOS 10 / El Captain

Dependency manager + version: pod

Linked issues

#3238

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 34 (13 by maintainers)

Most upvoted comments

Bingo. That’s the issue. I have Realm migration handling code run early in the app startup, and it was initialising the Realm files 1st time. Now I’ve fixed it, and it seems like our code works!

I have:

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *appSupportDirPath = [paths firstObject];
NSString *realmPath = [appSupportDirPath stringByAppendingPathComponent:@"default.realm"];
config.fileURL = [NSURL fileURLWithPath:realmPath];
[RLMRealmConfiguration setDefaultConfiguration:config];

image

Realm files are gone. The BZip’ed JSON files are my data files.

Should we put a note in Realm guide on default location of the database being in conflict with UIFileSharingEnabled ?

@invisible66 yes, I have a solution that allows me to pass review. I use this code Screenshot 2019-12-04 at 14 32 49

@jpsim Should we document somehow that UIFileSharingEnabled collides with default Realm settings ?

Well, this thread has certainly saved me some precious time. Not a common occurrence, but it surely does clash with built-in functionality of UIFileSharingEnabled, so I suppose a paragraph in docs wouldn’t hurt either.

NSFileProtection is about encryption, so doesn’t seem relevant here. You may be thinking of NSURLIsExcludedFromBackupKey which will prevent a given file from being backed up. I don’t think that has any impact on the iTunes file sharing UI though.

We cannot change the default path of Realm files without breaking all existing apps that are using the default path. The only solution here, IMO, is for anyone that wants their app to store Realm files in different location, for whatever reason, to specify a different path in their configuration.

@sergstav Thank you so much. You saved my day 😃