Releases: realm/realm-swift
Releases · realm/realm-swift
v10.34.0
Swift 5.5 is no longer supported. Swift 5.6 (Xcode 13.3) is now the minimum supported version.
The prebuilt binary for Carthage is now build with Xcode 14.2.
Enhancements
- Improve performance of creating Projection objects and of change notifications on projections (PR #8050).
- Allow initialising any sync configuration with
cancelAsyncOpenOnNonFatalErrors
. - Improve performance of Combine value publishers which do not use the object/collection changesets a little.
- All public types have been audited for sendability and are now marked as Sendable when applicable. A few types which were incidentally not thread-safe but make sense to use from multiple threads are now thread-safe.
- Add support for building Realm with strict concurrency checking enabled.
Fixed
- Fix bad memory access exception that can occur when watching change streams. PR #8039.
- Object change notifications on projections only included the first projected property for each source property (PR #8050, since v10.21.0).
@AutoOpen
failed to open flexible sync Realms while offline (#7986, since v10.27.0).- Fix "Publishing changes from within view updates is not allowed" warnings when using
@ObservedResults
or@ObservedSectionedResults
(#7908). - Fix "Publishing changes from within view updates is not allowed" warnings when using
@AutoOpen
or@AsyncOpen
. (#7908). - Defer
Realm.asyncOpen
execution on@AsyncOpen
and@AutoOpen
property wrappers until all the environment values are set. This will guarantee the configuration and partition value are set set before opening the realm. (#7931, since v10.12.0). @ObservedResults.remove()
could delete the wrong object if a write on a background thread which changed the index of the object being removed occurred at a very specific time (since v10.6.0).
Compatibility
- Realm Studio: 11.0.0 - 12.0.0. 13.0.0 is currently incompatible.
- APIs are backwards compatible with all previous releases in the 10.x.y series.
- Carthage release for Swift is built with Xcode 14.2.
- CocoaPods: 1.10 or later.
- Xcode: 13.3-14.2.
v10.33.0
Enhancements
- Flexible sync subscription state will change to
SyncSubscriptionState.pending
(RLMSyncSubscriptionStatePending
) while waiting for the server to have sent all pending history after a bootstrap and before marking a subscription as Complete. (#5795) - Add custom column names API, which allows to set a different column name in the realm from the one used in your object declaration.
This is very helpful in cases where you want to name a property differently from your
class Person: Object { @Persisted var firstName: String @Persisted var birthDate: Date @Persisted var age: Int override class public func propertiesMapping() -> [String: String] { ["firstName": "first_name", "birthDate": "birth_date"] } }
Device Sync
JSON schema. This API is only available for old and modern object declaration syntax on theRealmSwift
SDK. - Flexible sync bootstraps now apply 1MB of changesets per write transaction rather than applying all of them in a single write transaction. (Core PR #5999).
Fixed
- Fix a race condition which could result in "operation cancelled" errors being delivered to async open callbacks rather than the actual sync error which caused things to fail (Core PR #5968, since the introduction of async open).
- Fix database corruption issues which could happen if an application was terminated at a certain point in the process of comitting a write transaciton. (Core PR #5993, since v10.21.1)
@AsyncOpen
and@AutoOpen
would begin and then cancel a second async open operation (PR #8038, since v10.12.0).- Changing the search text when using the searchable SwiftUI extension would trigger multiple updates on the View for each change (PR #8038, since v10.19.0).
- Changing the filter or search properties of an
@ObservedResults
or@ObservedSectionedResults
would trigger up to three updates on the View (PR #8038, since v10.6.0). - Fetching a user's profile while the user logs out would result in an assertion failure. (Core PR #6017, since v10.8.0)
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 14.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
Internal
- Upgraded realm-core from 12.11.0 to 12.13.0
v10.32.3
Fixed
- Fix name lookup errors when importing Realm Swift built in library evolution mode ((#8014).
- The prebuilt watchOS library in the objective-c release package was missing an arm64 slice. The Swift release package was uneffected (PR #8016).
- Fix issue where
RLMUserAPIKey.key
/UserAPIKey.key
incorrectly returned the name of the API key instead of the key itself. (#8021, since v10.0.0)
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 14.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
v10.32.2
Switch to building the Carthage release with Xcode 14.1.
Fixed
- Fix linker errors when building a release build with Xcode 14.1 when
installing via SPM (#7995).
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 14.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
v10.32.1
Enhancements
- Improve performance of client reset with automatic recovery and converting top-level tables into embedded tables (Core #5897).
Realm.Error
is now a typealias forRLMError
rather than a manually-defined version of what the automatic bridging produces. This should have no effect on existing working code, but the manual definition was missing a few things supplied by the automatic bridging.- Some sync errors sent by the server include a link to the server-side logs associated with that error. This link is now exposed in the
serverLogURL
property onSyncError
(orRLMServerLogURLKey
userInfo field when using NSError).
Fixed
- Many sync and app errors were reported using undocumented internal error codes and/or domains and could not be programmatically handled. Some notable things which now have public error codes instead of unstable internal ones:
Realm.Error.subscriptionFailed
: The server rejected a flexible sync subscription.AppError.invalidPassword
: A login attempt failed due to a bad password.AppError.accountNameInUse
: A registration attempt failed due to the account name being in use.AppError.httpRequestFailed
: A HTTP request to Atlas App Services
completed with an error HTTP code. The failing code is available in the
httpStatusCode
property.- Many other less common error codes have been added to
AppError
. - All sync errors other than
SyncError.clientResetError
reported incorrect
error codes.
(since v10.0.0).
UserAPIKey.objectId
was incorrectly bridged to Swift asRLMObjectId
toObjectId
. This may produce warnings about an unneccesary cast if you were previously casting it to the correct type (since v10.0.0).- Fixed an assertion failure when observing change notifications on a sectioned result, if the first modification was to a linked property that did not cause the state of the sections to change. (Core #5912, since the introduction of sectioned results in v10.29.0)
- Fix a use-after-free if the last external reference to an encrypted synchronized Realm was closed between when a client reset error was received and when the download of the new Realm began. (Core #5949, since 10.28.4).
- Fix an assertion failure during client reset with recovery when recovering a list operation on an embedded object that has a link column in the path prefix to the list from the top level object. (Core #5957, since introduction of automatic recovery in v10.32.0).
- Creating a write transaction which is rejected by the server due to it exceeding the maximum transaction size now results in a client reset error instead of synchronization breaking and becoming stuck forever (Core #5209, since v10).
- Opening an unencrypted file with an encryption key would sometimes report a misleading error message that indicated that the problem was something other than a decryption failure (Core #5915, since 0.89.0).
- Fix a rare deadlock which could occur when closing a synchronized Realm immediately after committing a write transaction when the sync worker thread has also just finished processing a changeset from the server (Core #5948).
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 14.0.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
Internal
- Upgraded realm-core from 12.9.0 to 12.11.0.
v10.32.0
Enhancements
- Add
.recoverUnsyncedChanges
(RLMClientResetModeRecoverUnsyncedChanges
) and
.recoverOrDiscardUnsyncedChanges
(RLMClientResetModeRecoverOrDiscardUnsyncedChanges
) behaviors toClientResetMode
(RLMClientResetMode
).- The newly added recover modes function by downloading a realm which reflects the latest
state of the server after a client reset. A recovery process is run locally in an
attempt to integrate the server state with any local changes from before the
client reset occurred.
The changes are integrated with the following rules:- Objects created locally that were not synced before client reset, will be integrated.
- If an object has been deleted on the server, but was modified on the client, the delete takes precedence and the update is discarded.
- If an object was deleted on the client, but not the server, then the client delete instruction is applied.
- In the case of conflicting updates to the same field, the client update is applied.
- The client reset process will fallback to
ClientResetMode.discardUnsyncedChanges
if the recovery process fails in.recoverOrDiscardUnsyncedChanges
. - The client reset process will fallback to
ClientResetMode.manual
if the recovery process fails in.recoverUnsyncedChanges
. - The two new swift recovery modes support client reset callbacks:
.recoverUnsyncedChanges(beforeReset: ((Realm) -> Void)? = nil, afterReset: ((Realm, Realm) -> Void)? = nil)
. - The two new Obj-C recovery modes support client reset callbacks in
notifyBeforeReset
andnotifyAfterReset
for both[RLMUser configurationWithPartitionValue]
and[RLMUser flexibleSyncConfigurationWithClientResetMode]
For more detail on client reset callbacks, seeClientResetMode
,RLMClientResetBeforeBlock
,
RLMClientResetAfterBlock
, and the 10.25.0 changelog entry.
- The newly added recover modes function by downloading a realm which reflects the latest
- Add two new additional interfaces to define a manual client reset handler:
- Add a manual callback handler to
ClientResetMode.manual
->ClientResetMode.manual(ErrorReportingBlock? = nil)
. - Add the
RLMSyncConfiguration.manualClientResetHandler
property (typeRLMSyncErrorReportingBlock
). - These error reporting blocks are invoked in the event of a
RLMSyncErrorClientResetError
. - See
ErrorReportingBlock
(RLMSyncErrorReportingBlock
), andClientResetInfo
for more detail. - Previously, manual client resets were handled only through the
SyncManager.ErrorHandler
. You have the
option, but not the requirement, to define manual reset handler in these interfaces.
Otherwise, theSyncManager.ErrorHandler
is still invoked during the manual client reset process. - These new interfaces are only invoked during a
RLMSyncErrorClientResetError
. All other sync errors
are still handled in theSyncManager.ErrorHandler
. - See 'Breaking Changes' for information how these interfaces interact with an already existing
SyncManager.ErrorHandler
.
- Add a manual callback handler to
Breaking Changes
- The default
clientResetMode
(RLMClientResetMode
) is switched from.manual
(RLMClientResetModeManual
)
to.recoverUnsyncedChanges
(RLMClientResetModeRecoverUnsyncedChanges
).- If you are currently using
.manual
and continue to do so, the only change
you must explicitly make is designating manual mode in
yourRealm.Configuration.SyncConfiguration
s, since they will now default to.recoverUnsyncedChanges
. - You may choose to define your manual client reset handler in the newly
introducedmanual(ErrorReportingBlock? = nil)
orRLMSyncConfiguration.manualClientResetHandler
, but this is not required.
TheSyncManager.errorHandler
will still be invoked during a client reset if
no callback is passed into these new interfaces.
- If you are currently using
Deprecations
ClientResetMode.discardLocal
is deprecated in favor ofClientResetMode.discardUnsyncedChanges
.
The reasoning is that the name better reflects the effect of this reset mode. There is no actual
difference in behavior.
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 14.0.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
v10.31.0
The prebuilt binary for Carthage is now build with Xcode 14.0.1.
Enhancements
- Cut the runtime of aggregate operations on large dictionaries in half (Core #5864).
- Improve performance of aggregate operations on collections of objects by 2x to 10x (Core #5864). Greatly improve the performance of sorting or distincting a Dictionary's keys or values. The most expensive operation is now performed O(log N) rather than O(N log N) times, and large Dictionaries can see upwards of 99% reduction in time to sort. (Core #5166)
- Add support for changing the deployment location for Atlas Apps. Previously this was assumed to be immutable (Core #5648).
- The sync client will now yield the write lock to other threads which are waiting to perform a write transaction even if it still has remaining work to do, rather than always applying all changesets received from the server even when other threads are trying to write. (Core #5844).
- The sync client no longer writes an unused temporary copy of the changesets received from the server to the Realm file (Core #5844).
Fixed
- Setting a
List
property withResults
no longer throws an unrecognized selector exception (since 10.8.0-beta.2) RLMProgressNotificationToken
andProgressNotificationToken
now hold a strong reference to the sync session, keeping it alive until the token is deallocated or invalidated, as the other notification tokens do. (#7831, since v2.3.0).- Results permitted some nonsensical aggregate operations on column types which do not make sense to aggregate, giving garbage results rather than reporting an error (Core #5876, since v5.0.0).
- Upserting a document in a Mongo collection would crash if the document's id type was anything other than ObjectId (since v10.0.0).
- Fix a use-after-free when a sync session is closed and the app is destroyed at the same time (Core #5752, since v10.19.0).
Deprecations
RLMUpdateResult.objectId
has been deprecated in favor ofRLMUpdateResult.documentId
to support reporting document ids which are not object ids.
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 14.0.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14.1.
Internal
- Upgraded realm-core from 12.7.0 to 12.9.0
v10.30.0
Fixed
- Incoming links from
RealmAny
properties were not handled correctly when migrating an object type from top-level to embedded.RealmAny
properties currently cannot link to embedded objects. (Core #5796, since 10.8.0). Realm.refresh()
sometimes did not actually advance to the latest version. It attempted to be semi-non-blocking in a very confusing way which resulted in it sometimes advancing to a newer version that is not the latest version, and sometimes blocking until notifiers are ready so that it could advance to the latest version. This behavior was undocumented and didn't work correctly, so it now always blocks if needed to advance to the latest version. (#7625, since v0.98.0).- Fix the most common cause of thread priority inversions when performing writes on the main thread. If beginning the write transaction has to wait for the background notification calculations to complete, that wait is now done in a QoS-aware way. (#7902)
- Subscribing to link properties in a flexible sync Realm did not work due to a mismatch between what the client sent and what the server needed. (Core #5409)
- Attempting to use
AsymmetricObject
with partition-based sync now reports a sensible error much earlier in the process. Asymmetric sync requires using flexible sync. (Core #5691, since 10.29.0). - Case-insensitive but diacritic-sensitive queries would crash on 4-byte UTF-8 characters (Core #5825, since v2.2.0)
- Accented characters are now handled by case-insensitive but diacritic-sensitive queries. (Core #5825, since v2.2.0)
Breaking Changes
-[RLMASLoginDelegate authenticationDidCompleteWithError:]
has been renamed to-[RLMASLoginDelegate authenticationDidFailWithError:]
to comply with new app store requirements. This only effects the obj-c API. (#7945)
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.4.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1 - 14.
Internal
- Upgraded realm-core from 12.6.0 to 12.7.0
v10.29.0
Enhancements
- Add support for asymmetric sync. When a class inherits from
AsymmetricObject
, objects created are synced unidirectionally to the server and cannot be queried or read locally.
class PersonObject: AsymmetricObject {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var name: String
@Persisted var age: Int
}
try realm.write {
// This will create the object on the server but not locally.
realm.create(PersonObject.self, value: ["_id": ObjectId.generate(),
"name": "Dylan",
"age": 20])
}
- Add ability to section a collection which conforms to
RealmCollection
,RLMCollection
. Collections can be sectioned by a unique key retrieved from a keyPath or a callback and will return an instance ofSectionedResults
/RLMSectionedResults
. Each section in the collection will be an instance ofResultsSection
/RLMSection
which gives access to the elements corresponding to the section key.SectionedResults
/RLMSectionedResults
andResultsSection
/RLMSection
have the ability to be observed.class DemoObject: Object { @Persisted var title: String @Persisted var date: Date var firstLetter: String { return title.first.map(String.init(_:)) ?? "" } } var sectionedResults: SectionedResults<String, DemoObject> // ... sectionedResults = realm.objects(DemoObject.self) .sectioned(by: \.firstLetter, ascending: true)
- Add
@ObservedSectionedResults
for SwiftUI support. This property wrapper type retrieves sectioned results from a Realm using a keyPath or callback to determine the section key.struct DemoView: View { @ObservedSectionedResults(DemoObject.self, sectionKeyPath: \.firstLetter) var demoObjects var body: some View { VStack { List { ForEach(demoObjects) { section in Section(header: Text(section.key)) { ForEach(section) { object in MyRowView(object: object) } } } } } } }
- Add automatic handing for changing top-level objects to embedded objects in migrations. Any objects of the now-embedded type which have zero incoming links are deleted, and objects with multiple incoming links are duplicated. This happens after the migration callback function completes, so there is no functional change if you already have migration logic which correctly handles this. (Core #5737).
- Improve performance when a new Realm file connects to the server for the first time, especially when significant amounts of data has been written while offline. (Core #5772)
- Shift more of the work done on the sync worker thread out of the write transaction used to apply server changes, reducing how long it blocks other threads from writing. (Core #5772)
- Improve the performance of the sync changeset parser, which speeds up applying changesets from the server. (Core #5772)
Fixed
- Fix all of the UBSan failures hit by our tests. It is unclear if any of these manifested as visible bugs. (Core #5665)
- Upload completion callbacks were sometimes called before the final step of interally marking the upload as complete, which could result in calling
Realm.writeCopy()
from the completion callback failing due to there being unuploaded changes. (Core #4865). - Writing to a Realm stored on an exFAT drive threw the exception "fcntl() with F_BARRIERFSYNC failed: Inappropriate ioctl for device" when a write transaction needed to expand the file. (Core #5789, since 10.27.0)
- Syncing a Decimal128 with big significand could result in a crash. (Core #5728)
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.4.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14 RC.
Internal
- Upgraded realm-core from 12.5.1 to 12.6.0
v10.28.7
Enhancements
- Add prebuilt binaries for Xcode 14 to the release package.
Fixed
- Fix archiving watchOS release builds with Xcode 14.
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.4.1.
- CocoaPods: 1.10 or later.
- Xcode: 13.1-14 beta 6.