Hi I'm upgrading my SPM Packages to Swift 6.2, and also upgrading Factory to 2.5.3
I'm registering a dependency for the main actor
extension Container {
@MainActor
var mainActorType: Factory<MainActorType> {
self { @MainActor in SomeMainActorType() }
}
}
And I have a XCTestCase also for the main actor where I override the registration
@MainActor
final class MyTests: XCTestCase {
private var mockMainActorInstance: MockMainActorType!
override func setUp() async throws {
Container.shared.mainActorType.register { params in
self.mockMainActorInstance = MockMainActorType(withParams: params)
return self.mockMainActorInstance
}
}
}
But I get the error
Main actor-isolated property 'mockMainActorInstance' can not be referenced from a Sendable closure
Looking at the Factory code it looks like adding @mainactor to the closure parameter could/should resolve this issue
public extension Factory {
@discardableResult
func registerMain(factory: @MainActor @escaping () -> T) -> Self {
self.register(factory: factory)
return self
}
}
Hi I'm upgrading my SPM Packages to Swift 6.2, and also upgrading Factory to 2.5.3
I'm registering a dependency for the main actor
And I have a XCTestCase also for the main actor where I override the registration
But I get the error
Main actor-isolated property 'mockMainActorInstance' can not be referenced from a Sendable closureLooking at the Factory code it looks like adding @mainactor to the closure parameter could/should resolve this issue