Realm v10.6.0 Release Notes

Release Date: 2021-02-15 // about 3 years ago
  • ✨ Enhancements

    • ➕ Add @StateRealmObject for SwiftUI support. This property wrapper type instantiates an observable object on a View. Use in place of SwiftUI.StateObject for Realm Object, List, and EmbeddedObject types.
    • ➕ Add @ObservedRealmObject for SwiftUI support. This property wrapper type subscribes to an observable object and invalidates a view whenever the observable object changes. Use in place of SwiftUI.ObservedObject for Realm Object, List, or EmbeddedObject types.
    • ➕ Add @ObservedResults for SwiftUI support. This property wrapper type retrieves results from a Realm. The results use the realm configuration provided by the environment value EnvironmentValues.realmConfiguration.
    • ➕ Add EnvironmentValues.realm and EnvironmentValues.realmConfiguration for Realm and Realm.Configuration types respectively. Values can be injected into views using the View.environment method, e.g., MyView().environment(\.realmConfiguration, Realm.Configuration(fileURL: URL(fileURLWithPath: "myRealmPath.realm"))). The value can then be declared on the example MyView as @Environment(\.realm) var realm.
    • ➕ Add SwiftUI.Binding extensions where Value is of type Object, List, or EmbeddedObject. These extensions expose methods for wrapped write transactions, to avoid boilerplate within views, e.g., TextField("name", $personObject.name) or $personList.append(Person()).
    • ➕ Add Object.bind and EmbeddedObject.bind for SwiftUI support. This allows you to create bindings of realm properties when a propertyWrapper is not available for you to do so, e.g., TextField("name", personObject.bind(\.name)).
    • 🔀 The Sync client now logs error messages received from server rather than just the size of the error message.
    • 🔀 Errors returned from the server when sync WebSockets get closed are now captured and surfaced as a SyncError.
    • 👌 Improve performance of sequential reads on a Results backed directly by a Table (i.e. realm.object(ClasSName.self) with no filter/sort/etc.) by 50x.
    • Orphaned embedded object types which are not linked to by any top-level types are now better handled. Previously the server would reject the schema, resulting in delayed and confusing error reporting. Explicitly including an orphan in objectTypes is now immediately reported as an error when opening the Realm, and orphans are automatically excluded from the auto-discovered schema when objectTypes is not specified.

    🛠 Fixed

    • Reading from a Results backed directly by a Table (i.e. realm.object(ClasSName.self) with no filter/sort/etc.) would give incorrect results if the Results was constructed and accessed before creating a new object with a primary key less than the smallest primary key which previously existed. (#7014, since v5.0.0).
    • 🔀 During synchronization you might experience crash with "Assertion failed: ref + size <= next->first". (Core #4388)

    Compatibility

    • Realm Studio: 10.0.0 or later.
    • 🚀 APIs are backwards compatible with all previous releases in the 10.x.y series.
    • 🚀 Carthage release for Swift is built with Xcode 12.4.
    • CocoaPods: 1.10 or later.

    Internal

    • ⬆️ Upgraded realm-core from v10.4.0 to v10.5.0