Realm is a mobile database: a replacement for Core Data & SQLite
This version introduces a new Realm file format version (v24). Opening existing Realm files will automatically upgrade the files, making them unable to be opened by older versions. This upgrade process should typically be very fast unless you have large Sets of AnyRealmValue, String, or Data, which have to be rewritten.
A backup will automatically be created next to the Realm before performing the upgrade. Downgrading to older versions of Realm will attempt to automatically restore the backup, or it will be deleted after three months.
REALM_EXTRA_BUILD_ARGUMENTS
environment variable in build.sh
. (PR #8413). Thanks, @hisaac!public class Location: EmbeddedObject {
@Persisted private var coordinates: List<Double>
@Persisted private var type: String = "Point"
public var latitude: Double { return coordinates[1] }
public var longitude: Double { return coordinates[0] }
convenience init(_ latitude: Double, _ longitude: Double) {
self.init()
// Longitude comes first in the coordinates array of a GeoJson document
coordinates.append(objectsIn: [longitude, latitude])
}
}
Geospatial queries (geoWithin
) can only be executed on such a type of objects and will throw otherwise. The queries can be used to filter objects whose points lie within a certain area, using the following pre-established shapes (GeoBox
, GeoPolygon
, GeoCircle
).
class Person: Object {
@Persisted var name: String
@Persisted var location: Location? // GeoJson embedded object
}
let realm = realmWithTestPath()
try realm.write {
realm.add(PersonLocation(name: "Maria", location: Location(latitude: 55.6761, longitude: 12.5683)))
}
let shape = GeoBox(bottomLeft: (55.6281, 12.0826), topRight: (55.6762, 12.5684))!
let locations = realm.objects(PersonLocation.self).where { $0.location.geoWithin(shape) })
A filter
or NSPredicate
can be used as well to perform a Geospatial query.
let shape = GeoPolygon(outerRing: [(-2, -2), (-2, 2), (2, 2), (2, -2), (-2, -2)], holes: [[(0, 0), (1, 1), (-1, 1), (0, 0)]])!
let locations = realm.objects(PersonLocation.self).filter("location IN %@", shape)
let locations = realm.objects(PersonLocation.self).filter(NSPredicate(format: "location IN %@", shape))
baseURL
field of AppConfiguration
can now be updated, rather than the value being persisted between runs of the application in the metadata storage. (Core #7201)@Persisted
's Encodable implementation did not allow the encoder to customize the encoding of values, which broke things like JSONEncoder's dateEncodingStrategy
(#8425).schemaVersion
field of Realm.Configuration
must now always be zero for synchronized Realms. Schema versions are currently not applicable to synchronized Realms and the field was previously not read.SyncSession.ProgressDirection
and SyncSession.ProgressMode
were missing
Sendable
annotations (PR #8435).Realm.Error.subscriptionFailed
was reported with the incorrect error
domain, making it impossible to catch (since v10.42.2, PR #8435).SyncSession.ProgressDirection
and SyncSession.ProgressMode
were missing
Sendable
annotations (PR #8435).Realm.Error.subscriptionFailed
was reported with the incorrect error
domain, making it impossible to catch (since v10.42.2, PR #8435).SyncSession.reconnect()
while a reconnect after a non-fatal error was pending would result in an assertion failure mentioning "!m_try_again_activation_timer" if another non-fatal error was received (Core #6961).