This page details considerations when using Realm on tvOS.
Avoid storing important user data in a realm on tvOS. Instead, it's best to treat Realm as a rebuildable cache.
The reason for this has to do with where Realm writes its
Realm files. On other Apple platforms,
Realm writes its Realm files to the "Documents"
directory. Because tvOS restricts writes to that directory, the
default Realm file location on tvOS is instead
tvOS can purge files in that directory at any time, so reliable
long-term persistence is not possible. For cloud-backed persistence
on tvOS, consider using Device Sync.
Browse our tvOS examples for sample tvOS apps that demonstrate how to use Realm as an offline cache.
let fileUrl = FileManager.default .containerURL(forSecurityApplicationGroupIdentifier: "group.com.mongodb.realm.examples.extension")! .appendingPathComponent("Library/Caches/default.realm")