Build for tvOS
When you're using Atlas Device SDK to build for Apple's tvOS, keep these important considerations in mind.
Tip
See also:
Avoid Storing Important User Data
Avoid storing important user data in the database on tvOS. Instead, it's best to treat the SDK as a rebuildable cache.
Note
The reason for this has to do with where the SDK writes its
database files. On other Apple
platforms, the SDK writes its database files to the "Documents"
directory. Because tvOS restricts writes to that directory, the
default database file location on tvOS is instead NSCachesDirectory
.
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.
You can also use the SDK as an initial data source by bundling prebuilt database files in your app. Note that the App Store guidelines limit your app size to 4GB.
Tip
Browse our tvOS examples for sample tvOS apps that demonstrate how to use the SDK as an offline cache.
Share Database Files with TV Services Extensions
To share a database file between a
tvOS app and a TV services extension such as Top Shelf, use the
Library/Caches/
directory in the shared container for the
application group:
let fileUrl = FileManager.default .containerURL(forSecurityApplicationGroupIdentifier: "group.com.mongodb.realm.examples.extension")! .appendingPathComponent("Library/Caches/default.realm")