I tried that, it did not solve the problem. There are, in fact, two:
• If the view with the EditButton does not have a parent view that is a NavigationStack (or perhaps types of views), there is no toolbar, and thus there is no edit button. (That is, if ContentView.swift does not contain a NavigationStack, then there is no toolbar.)
• If I put a NavigationStack in ContentView, then there is a toolbar and an Edit button, but edit mode is not enabled the first time I click on the Edit button
If I add
.toolbar {
EditButton()
}
.onChange(of: self.editMode?.wrappedValue) { o, v in
print("editMode \(o) -> \(v)")
}
then when I click on the button the first time, it prints
editMode Optional(SwiftUI.EditMode.inactive) -> Optional(SwiftUI.EditMode.active)
and... never again prints anything, although edit mode clearly does change.