I'm trying to implement a list in a Multiplatform implementation here is my implementation:
struct ContentView: View {
var body: some View {
List {
Section(header: Text("Header"), footer: Text("Footer")){
ForEach(0..<5){
Text("\($0)")
.tag($0)
}
}
#if os(iOS)
.listStyle(GroupedListStyle())
#endif
}
}
}
But on this line:
.listStyle(GroupedListStyle())
I'm getting this error:
Unexpected platform condition (expected `os`, `arch`, or `swift`)
Any of you knows a way around this error?
I'll really appreciate your help
SwiftUI doesn't like conditional compilation code very much.
Try something like this:
Or
You can also use a variation of the
func
with a returnedself
for modifiers that aren't appropriate. I also used it to make.environment
conditional.