When attempting to compile an existing project with Swift 6, default isolation set to MainActor and approachable concurrency enabled, all awakeFromNib
functions lead to the following compile error:
"Main actor-isolated instance method 'awakeFromNib()' has different actor isolation from nonisolated overridden declaration"
I've seen articles before approachable concurrency stating that one remedy is to wrap code within the function with MainActor.assumeIsolated{ }
. However, that no longer addresses the error.
One combination of changes that removes the error is doing the following:
nonisolated override func awakeFromNib() {
super.awakeFromNib()
MainActor.assumeIsolated {
...
}
}
Honestly, that's a mess. Long term, we are looking to remove all these functions, but does anyone have a better solution?