brustolin
(Dhiogo Brustolin)
August 7, 2024, 1:07pm
1
I have this code working with Xcode 15, but it breaks when compiling it with Xcode 16:
class SelectorController : UITableViewController {
private let repository = Repository.shared
init() {
super.init(style: .grouped) //ERROR: Property 'self.repository' not initialized at super.init call
}
}
What changed? I could not find any update on the docs related to this.
Edit:
If I remove @MainActor from Repository
the error goes away.
1 Like
eskimo
(Quinn “The Eskimo!”)
August 8, 2024, 8:47am
2
Which version of Xcode 16 beta is this? And are you in Swift 6 language mode?
I tried replicating your problem with Xcode 16.0b5 and I saw two different results:
My code is below.
Share and Enjoy
Quinn “The Eskimo!” @ DTS @ Apple
[1] It’s centred on whether init()
is main-actor-isolated or not. Indeed, it’s exactly this issue .
import UIKit
@MainActor
class Repository {
static let shared = Repository()
}
class SelectorController: UITableViewController {
private let repository = Repository.shared
init() {
super.init(style: .grouped)
}
required init?(coder: NSCoder) {
fatalError()
}
}
2 Likes
brustolin
(Dhiogo Brustolin)
August 8, 2024, 12:06pm
3
Thanks for the reply.
Im using Xcode 16b5 and Swift 5 but with SWIFT_STRICT_CONCURRENCY
as complete
to prepare to Swift 6.
I thought that since UITableViewController
is annotated with @MainActor
, the constructor would also be on the MainActor
.
If this is how Swift 6 will behave, I would appreciate any reading suggestions to catch up with the changes. As I mentioned before, this error doesn't occur with Xcode 15 using the same settings.
Thank you very much!!
vns
August 8, 2024, 12:16pm
4
I think this might be relative to other topic:
1 Like