iOS 15+ (Swift 5.5 +)
SwiftUI has built-in support for rendering Markdown
To create a link, enclose the link's text in brackets (e.g., [Duck Duck Go]) and then follow it immediately with the URL in parentheses (e.g., (https://duckduckgo.com)).
Text("[Privacy Policy](https://example.com)")
https://www.markdownguide.org/basic-syntax/#links
String variable
- Use
init(_ value: String)
Creates a localized string key from the given string value.
let link = "[Duck Duck Go](https://duckduckgo.com)"
Text(.init(link))
String interpolation
- Use
init(_ value: String)
Creates a localized string key from the given string value.
let url = "https://duckduckgo.com"
let link = "[Duck Duck Go](\(url))"
Text(.init(link))
Attributed text
- Use
init(_ attributedContent: AttributedString)
Creates a text view that displays styled attributed content.
let markdownLink = try! AttributedString(markdown: "[Duck Duck Go](https://duckduckgo.com)")
Text(markdownLink)
Similar question:
Making parts of text bold in SwiftUI
Use the Link View
A control for navigating to a URL.
Link("Privacy Policy", destination: URL(string: "https://example.com")!)
https://developer.apple.com/documentation/swiftui/link