Thanks for the feedback, you were right the error was misleading, i have found the actual culprit of the problem:
It's the PhotosPicker
, updating the same example, this is reproducible.
struct FooView: View {
@MainActor @State var bar: Bool = false
var body: some View {
PhotosPicker(selection: .constant(nil),
photoLibrary: .shared()) // PICKER CLOSURE
{
if bar { // 1. WARNING
ProgressView()
.progressViewStyle(.circular) // 2. WARNING
}
}
}
}
The warning has also changed to
Main actor-isolated property 'bar' can not be referenced from a Sendable closure
The init of PhotoLibrary
, in the standard PhotosUI
module has the following initializer:
@MainActor @preconcurrency public struct PhotosPicker<Label> : View where Label : View {
@preconcurrency nonisolated public init(selection: Binding<PhotosPickerItem?>,
matching filter: PHPickerFilter? = nil,
preferredItemEncoding: PhotosPickerItem.EncodingDisambiguationPolicy = .automatic,
photoLibrary: PHPhotoLibrary, @ViewBuilder
label: @Sendable () -> Label) // THE TRIGGERING CLOSURE
}
I still don't know how to fix it tho.