Fatal error: No ObservableObject of type Keyboard found. A View.environmentObject(_:) for Keyboard may be missing as an ancestor of this view.: file SwiftUI, line 0

#24 · closed · 3 comments

View on GitHub ↗

wangrui460

![image](https://user-images.githubusercontent.com/11909313/117265086-73685480-ae86-11eb-88a0-8f93d0737a05.png) my sceneDelegate added environment this error shown when sheet a view, if you gesture to close but not close,error will show~

Comments

github-actions[bot]

Thanks for creating an issue!

wangrui460

[The solution is here](https://stackoverflow.com/questions/58743004/swiftui-environmentobject-error-may-be-missing-as-an-ancestor-of-this-view)

nickffox

This looks like a duplicate of #21. It sounds like there isn’t a `Keyboard` instance in the environment. Make sure you’ve added that in your `SceneDelegate` (or wherever you set up you’re environment). Here’s the link to the documentation showing [how to do this](https://github.com/nickffox/KeyboardObserving#1-add-a-keyboard-to-your-environment).