I am writing a SwiftUI App in Xcode 12.0 beta (12A6159), the app is intended to work on iOS13.5 and up.
I am instantiating ObservableObjects at one level of my View hierarchy in the View's init() function, passing them as appropriate using .environmentObject, then attempting to pick them up in @EnvironmentObject in Views several layers deeper.
The consuming Views are getting the error:
A View.environmentObject(_:) for ********* may be missing as an ancestor of this view.
After careful testing, I find that the EnvironmentObjects are not being passed through NavigationLink.
We already have the well known issue of these not being passed through .sheet presentation (a major inconvenience), now we are contending with the same issue with NavigationLink?
Is this intentional or a bug? Is there a workaround?
It is definitely not what I would consider my preferred design.
I am instantiating ObservableObjects at one level of my View hierarchy in the View's init() function, passing them as appropriate using .environmentObject, then attempting to pick them up in @EnvironmentObject in Views several layers deeper.
The consuming Views are getting the error:
A View.environmentObject(_:) for ********* may be missing as an ancestor of this view.
After careful testing, I find that the EnvironmentObjects are not being passed through NavigationLink.
We already have the well known issue of these not being passed through .sheet presentation (a major inconvenience), now we are contending with the same issue with NavigationLink?
Is this intentional or a bug? Is there a workaround?
It is definitely not what I would consider my preferred design.