github realm/realm-swift v10.25.0

latest releases: v20.0.0, v10.53.1, v10.53.0...
2 years ago

Synchronized Realm files written by this version cannot be opened by older versions of Realm. Existing files will be automatically upgraded when opened.

Non-synchronized Realm files remain backwards-compatible.

Enhancements

  • Add ability to use Swift Query syntax in @ObservedResults, which allows you to filter results using the where parameter.
  • Add ability to use MutableSet with StateRealmObject in SwiftUI.
  • Async/Await extensions are now compatible with iOS 13 and above when building with Xcode 13.3.
  • Sync changesets waiting to be uploaded to the server are now compressed, reducing the disk space needed when large write transactions are performed while offline or limited in bandwidth.(Core #5260).
  • Added new SyncConfiguration.clientResetMode and RLMSyncConfiguration.clientResetMode properties.
    • The values of these properties will dictate client behavior in the event of a client reset.
    • See below for information on ClientResetMode values.
    • clientResetMode defaults to .manual if not set otherwise.
  • Added new ClientResetMode and RLMClientResetMode enums.
    • These enums represent possible client reset behavior for SyncConfiguration.clientResetMode and RLMSyncConfiguration.clientResetMode, respectively.
    • .manual and RLMClientResetModeManual
      • The local copy of the Realm is copied into a recovery directory for safekeeping, and then deleted from the original location. The next time the Realm for that partition value is opened, the Realm will automatically be re-downloaded from MongoDB Realm, and can be used as normal.
      • Data written to the Realm after the local copy of the Realm diverged from the backup remote copy will be present in the local recovery copy of the Realm file. The re-downloaded Realm will initially contain only the data present at the time the Realm was backed up on the server.
      • rlmSync_clientResetBackedUpRealmPath and SyncError.clientResetInfo() are used for accessing the recovery directory.
    • .discardLocal and RLMClientResetDiscardLocal
      • All unsynchronized local changes are automatically discarded and the local state is automatically reverted to the most recent state from the server. Unsynchronized changes can then be recovered in a post-client-reset callback block (See changelog below for more details).
      • If RLMClientResetModeDiscardLocal is enabled but the client reset operation is unable to complete then the client reset process reverts to manual mode.
      • The realm's underlying object accessors remain bound so the UI may be updated in a non-disruptive way.
  • Added support for client reset notification blocks for .discardLocal and RLMClientResetDiscardLocal
    • RealmSwift implementation: discardLocal(((Realm) -> Void)? = nil, ((Realm, Realm) -> Void)? = nil)
      • RealmSwift client reset blocks are set when initializing the user configuration
      var configuration = user.configuration(partitionValue: "myPartition", clientResetMode: .discardLocal(beforeClientResetBlock, afterClientResetBlock))
      • The before client reset block -- ((Realm) -> Void)? = nil -- is executed prior to a client reset. Possible usage includes:
      let beforeClientResetBlock: (Realm) -> Void = { beforeRealm in
        var recoveryConfig = Realm.Configuration()
          recoveryConfig.fileURL = myRecoveryPath
          do {
            beforeRealm.writeCopy(configuration: recoveryConfig)
              /* The copied realm could be used later for recovery, debugging, reporting, etc. */
          } catch {
              /* handle error */
          }
      }
      • The after client reset block -- ((Realm, Realm) -> Void)? = nil) -- is executed after a client reset. Possible usage includes:
      let afterClientResetBlock: (Realm, Realm) -> Void = { before, after in
      /* This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc. */
      for object in before.objects(myClass.self) {
          let res = after.objects(myClass.self)
          if (res.filter("primaryKey == %@", object.primaryKey).first != nil) {
               /* ...custom recovery logic... */
          } else {
               /* ...custom recovery logic... */
          }
      }
    • Realm Obj-c implementation: Both before and after client reset callbacks exist as properties on RLMSyncConfiguration and are set at initialization.
        RLMRealmConfiguration *config = [user configurationWithPartitionValue:partitionValue
                                                              clientResetMode:RLMClientResetModeDiscardLocal
                                                            notifyBeforeReset:beforeBlock
                                                             notifyAfterReset:afterBlock];
      where beforeBlock is of type RLMClientResetBeforeBlock. And afterBlock is of type RLMClientResetAfterBlock.

Breaking Changes

  • Xcode 13.2 is no longer supported when building with Async/Await functions. Use Xcode 13.3 to build with Async/Await functionality.

Fixed

  • Adding a Realm Object to a ObservedResults or a collections using StateRealmObject that is managed by the same Realm would throw if the Object was frozen and not thawed before hand.
  • Setting a Realm Configuration for @ObservedResults using it's initializer would be overrode by the Realm Configuration stored in .environment(\.realmConfiguration, ...) if they did not match (Cocoa #7463, since v10.6.0).
  • Fix searchable component filter overriding the initial filter on @ObservedResults, (since v10.23.0).
  • Comparing Results, LinkingObjects or AnyRealmCollection when using Realm via XCFramework would result in compile time errors (Cocoa #7615, since v10.21.0)
  • Opening an encrypted Realm while the keychain is locked on macOS would crash (#7438).
  • Updating subscriptions while refreshing the access token would crash (Core #5343, since v10.22.0)
  • Fix several race conditions in SyncSession related to setting customRequestHeaders while using the SyncSession on a different thread.

Compatibility

  • Realm Studio: 11.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 13.3.
  • CocoaPods: 1.10 or later.
  • Xcode: 12.4-13.3.

Internal

  • Upgraded realm-core from v11.12.0 to v11.13.0

Don't miss a new realm-swift release

NewReleases is sending notifications on new releases.