1 min read
RealmLast Updated - Platform 21.0.0 - SDK 16.0.0
Realm is deprecated as of
v21.0 (v16.0) and will be removed in the future.
Realm is a third-party framework which provides a persistence layer around a local SQL database.
Prior to the addition of Core Data in
v21.0 (v16.0) the platform and SDK had a hard dependency on Realm.
This meant that clients that did not use features with persistence still included Realm in their codebase.
Why retire Realm?
Realm is a bad dependency. This is a bit of a bold statement as a lot of the community may swear by Realm, and Realm is a good tool for end applications. But, for a SAAS platform, and SDK, it is quite a large and often blocking dependency to have.
Realm adds 50 MB to 30 MB to an app's archive, over 1 minute to compile time on an M1 iMac (longer on other devices), and around 2 MB to app size (15% of our demo app's size) on the app store. It is also a dynamic Objective-C dependency which adds around 100ms to initial app launch time.
Realm limits us; we had to wait for it to support bitcode, we have to wait for it to support changes that Apple make.
We currently use Realm for storing very simple objects; often lists of identifiers with dates. Core Data and User Defaults are out of the box solutions that add no launch or app size penalties.
For all these reasons we have chosen to deprecate and retire Realm in favour of Core Data.
Migrate to Core Data
To retain user data, apps previously using Realm (any platform version below v21.0), must release using PoqRealm. After gaining sufficient adoption, those apps can later release without PoqRealm.
PoqRealm from version
You should have already added the
Platform repo package so you may be able to skip some of the package steps.
- Using the information above, add the
PoqRealmframework to your app.
- That's it!
The SDK will inject the
PoqRealm migrators before any other code is run so that they can be overridden.
PoqRealm framework has
StoreMigrator objects that use the
RealmStore.shared to retrieve all objects of a specified type.
Then migrate that data into a decorated
store; the default being the newer Core Data stores.
These migrators are registered dynamically if the framework is linked. No code is needed!