In my open source SwiftUI project a certain piece of code stopped working as of Xcode 11 b6 with the following error: Type of expression is ambiguous without more context.
at the line ModalView(currentModal: modal)
Everything worked without a hitch before that.
struct ContentView: View {
@EnvironmentObject var modalManager: ModalManager
var body: some View {
return ZStack {
ForEach($modalManager.modals) { modal in
ModalView(currentModal: modal) ## Error here
.environmentObject(self.modalManager)
}
}.onAppear(perform: {self.modalManager.fetchContent()})
}
}
Modal conforms to Identifiable
as shown below so that's not the issue.
struct Modal: Identifiable {
let id = UUID()
var content: AnyView
var position: ModalState = .base
var isFullscreenEnabled: Bool = false
var dragOffset: CGSize = .zero
}
Changing the ForEach loop to ForEach($modalManager.modals, id: \.self) { modal in ....}
returns a more confusing error message: Generic parameter 'B' could not be inferred
at the line setting the environment object.
Any help would be greatly appreciated.