-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: No observable object of type NavigationStack.Type found (iOS 13.0) #11
Comments
Hi @Faltenreich, thanks for your support. I've just managed to try the
The example exploits both a Can you provide me with a minimum viable example that causes the problem in order for me to help you debugging this issue? Thank you again. Matteo |
Hi @Faltenreich, any updates on this issue? Thanks for your help. |
Hi @matteopuc, thank you for your quick response! Our code looks something like that:
The ContentView itself is nested within some more Views. It contains one dynamic View that is conditionally generated through the ContentViewModel as @published property. Any other View is pushed via the NavigationStack.push() method which is accessed via the EnvironmentObject. Sadly I am not able to give you a full minimum viable example, since I am currently not at work and have no Apple hardware on my own in order to test it thoroughly. |
Hi @Faltenreich, thanks for replying and for posting this snippet that shows the issue. The problem is that: in SwiftUI you can access an
outside the navigation stack hierarchy, which begins with:
You just cannot access the navigation stack outside the hierarchy created by the
Now in your content view you can access the navigation stack.
|
Hi @matteopuc, you are absolutely right: this seems like a bug on our side. The EnvironmentObject within the ContentView even seems a bit useless, since it is not used at all. Does the declaration itself lead to this crash - and why only on iOS 13.0 and not on 13.1+? Either way, I will close this issue and thank you for your engagement. Your library is highly appreciated! :) |
Hello there!
First of all, thank you for this amazing library which fixed many problems we had while implementing a navigation stack on our own, e.g. when using conditional navigation via switch-case-statements.
While this library is working completely fine on iOS 13.1, 13.2.2 and 13.3, it leads to the following crash during app start on iOS 13.0:
Fatal error: No observable object of type NavigationStack.Type found. A View.environmentObject(_:) for NavigationStack.Type may be missing as an ancestor of this view.: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Monoceros_Sim/Monoceros-24.4/Core/EnvironmentObject.swift, line 161 Fatal error: No observable object of type NavigationStack.Type found. A View.environmentObject(_:) for NavigationStack.Type may be missing as an ancestor of this view.: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Monoceros_Sim/Monoceros-24.4/Core/EnvironmentObject.swift, line 161 (lldb)
There seems to be a problem with attaching NavigationStack as an EnvironmentObject. We were able to fix this issue by setting it as an EnvironmentObject by our own. This though is not possible with the library as it is, since its initializes is internal and therefor not accessible.
My question is now how to fix this issue on iOS 13.0. If there is no solution, maybe you could provide a public initializer as a workaround, so we can add the EnvironmentObject by our own.
Thanks in advance and best regards,
Philipp
The text was updated successfully, but these errors were encountered: