I have this code in one of my views:
struct TextFieldClearButton: ViewModifier {
@Binding var text: String
func body(content: Content) -> some View {
HStack {
content
if !text.isEmpty {
Button(
action: { self.text = "" },
label: {
Image(systemName: "delete.left")
.foregroundColor(Color(UIColor.opaqueSeparator))
}
)
}
}
}
}
I get two errors:
Type 'TextFieldClearButton' does not conform to protocol 'ViewModifier'Static method 'buildBlock' requires that 'Content' conform to 'View'
How can I get rid of these errors and make this modifier compile?
It looks like I can't use ViewModifier at all. Adding super simple case errors out too??:


You likely have a
struct/classin your project namedContentIf you have Xcode's standard dark theme the "mint"/"greenish" means it is "Project" defined.
When you are using Apple's definition it is pinkish/purple like
ViewModifier,View, andStringin your screenshot.Search for
struct Content,class Content,enum Content, etc. In your project, You will find the duplicate and then just change the name of the duplicate.It could also be a generic
<Content: SomeProtocol>or<Content>ortypealias ContentYou can confirm the duplicate by being more specific