From 2b01018ec9e01ad1143a6eddef0de31106861d24 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 2 May 2023 11:08:27 -0700 Subject: [PATCH] Remove incorrect @MainActor annotations (#8224) These functions are called on whatever thread a Realm is first opened on, not the main thread. --- CHANGELOG.md | 5 ++++- RealmSwift/AsymmetricObject.swift | 2 +- RealmSwift/EmbeddedObject.swift | 2 +- RealmSwift/Object.swift | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c609e8dbf8..791b6f8e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,10 @@ x.y.z Release notes (yyyy-MM-dd) ### Fixed * ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?) -* None. +* Several schema initialization functions had incorrect `@MainActor` + annotations, resulting in runtime warnings if the first time a Realm was + opened was on a background thread + ([#8222](https://github.com/realm/realm-swift/issues/8222), since v10.34.0). diff --git a/RealmSwift/AsymmetricObject.swift b/RealmSwift/AsymmetricObject.swift index 300c70fa9e..a431b0a22a 100644 --- a/RealmSwift/AsymmetricObject.swift +++ b/RealmSwift/AsymmetricObject.swift @@ -81,7 +81,7 @@ extension AsymmetricObject { It is not considered part of the public API. :nodoc: */ - @MainActor public override final class func _getProperties() -> [RLMProperty] { + public override final class func _getProperties() -> [RLMProperty] { return ObjectUtil.getSwiftProperties(self) } diff --git a/RealmSwift/EmbeddedObject.swift b/RealmSwift/EmbeddedObject.swift index 7acd8b0b8c..4cf8a135d7 100644 --- a/RealmSwift/EmbeddedObject.swift +++ b/RealmSwift/EmbeddedObject.swift @@ -114,7 +114,7 @@ extension EmbeddedObject: _RealmCollectionValueInsideOptional { It is not considered part of the public API. :nodoc: */ - @MainActor public override final class func _getProperties() -> [RLMProperty] { + public override final class func _getProperties() -> [RLMProperty] { return ObjectUtil.getSwiftProperties(self) } diff --git a/RealmSwift/Object.swift b/RealmSwift/Object.swift index 78fad3bf35..8b81fb4258 100644 --- a/RealmSwift/Object.swift +++ b/RealmSwift/Object.swift @@ -133,7 +133,7 @@ extension Object: _RealmCollectionValueInsideOptional { It is not considered part of the public API. :nodoc: */ - @MainActor public override final class func _getProperties() -> [RLMProperty] { + public override final class func _getProperties() -> [RLMProperty] { return ObjectUtil.getSwiftProperties(self) }