swift-composable-architecture: xcode hangs when adding @ObservedObject to ViewStore

When I am adding

@ObservedObject var viewStore: ViewStore<State, Action>

my Xcode hangs and I have to force quit it.

is there anything I am missing ?.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

@mathieutozer It’s definitely annoying, but almost always seems to be related to typos on the viewStore, right? Wish we could fix this but we’ll have to wait on Apple for this one. When you encounter the issue it doesn’t hurt to file a report at https://bugs.swift.org

One thing to save you a reboot in the future is to open Activity Monitor, go to the Memory tab, and kill any “swift” and “SourceKit” processes that are spiking in memory.

One thing that comes to mind, though, is that there seems to be a bug around dynamic member lookup (which ViewStore uses) and complex view builders, such that if you have a typo on the viewStore, it can hang builds indefinitely. You can usually zero in on the typo by either commenting out portions of the view that call to viewStore, or by explicitly accessing state through viewStore.state.

@stephencelis give me some time, I will check it send you to update. Thanks

@Shivam412 We still need a full example that we can try to compile to help. Can you zip up your project and post it here?

     var body:  some View { ... }

Can you post a full, compiling example? The culprit is likely in this body, but without a case that we can reproduce we’re not going to be able to help.