I'm trying to use a Link in a swiftUI view, and like every tutorial online, I'd like to use this one:
Link(destination: URL, label: () -> View)
It pops up as one of the autocomplete options, but as soon as I add it to my code, I get these three errors:
-
Extra arguments at positions #1, #2 in call
-
Missing arguments for parameters 'rel', 'href', 'method' in call
-
Static method 'buildExpression' requires that 'Link' conform to 'View'
It looks like XCode wants to force me to use this Link instead:
Link(rel: String, href: String, method: String)
but I don't understand why XCode won't let me use the first one. Does anyone know why this is happening?
I figured out the issue - there was a custom Link struct in the app I'm working on that takes precedence. Using SwiftUI.Link fixed the issue.
Further explanation here: https://stackoverflow.com/questions/71698728/textfield-viewmodifier-not-conforming-to-viewmodifier