Type '()' cannot conform to 'View'

Can anyone lend a hand on this code? thank you

Error message for SwiftUI sometimes are wrong.

Those Text() don't look right:

Text(location.date ?? "Unknown")

What is location.date? It must be String? because Text() only take String.

I suggest remove everything inside ForEach and add one thing at a time...

1 Like

The return value of the closure for the ForEach should be a single View, whereas your code is currently returning a bunch of them; the diagnostic seems a bit off and could probably be improved.

You need to group the various Text elements using a stack or another appropriate container for your use, and it should work then.


That’s okay if the ForEach closure uses a function builder as it will create a TupleView.

1 Like

Thanks to everyone that gives me a lot to work with , appreciated.