I cannot figure out how to fix this error:
Static method 'buildExpression' requires that 'ToolbarItemGroup<TupleView<(Button<Label<Text, Image>>, EditButton)>>' conform to 'View'
This is my code:
var body: some View {
NavigationView {
List {
ForEach(items) { item in
NavigationLink {
Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))")
} label: {
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
}
}
.onDelete(perform: deleteItems)
}
.navigationBarTitleDisplayMode(.automatic)
.toolbar {
ToolbarItemGroup(placement: .topBarTrailing) {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
EditButton()
}
ToolbarItem(placement: .principal) {
Label("hi")
}
}
}
}
Im using the Xcode 15 beta 2 to build for iOS 17
Xcode/Swift like sending you in different directions with errors messages, but this one I'm sure is easier to solve. The issue is not with the ToolbarItemGroup but with the Label in the ToolbarItem.
ToolbarItem(placement: .principal) {
Label("hi") // error is here
}
Label requires two arguments and you have only passed it one. Either change it to a Text view or provide the second parameter, either systemImage: or image:.