I have a prefix operator in my framework(Swift Package):
prefix operator !
public prefix func !(value: Binding<Bool>) -> Binding<Bool> {
Binding<Bool>(
get: { !value.wrappedValue },
set: { value.wrappedValue = !$0 }
)
}
Used in source code like this, xcode issues 'Cannot convert value of type 'Binding' to expected argument type 'Bool'. Cannot convert value of type 'Bool' to expected argument type 'Binding'':
struct TestView: View {
@State private var isOn = false
var body: some View
Toggle("", isOn: !$isOn)
}
}
After I copy the code of prefix operator ! into source code from framework, everything good.
Could it be that we could not use prefix operator from 'framework'?