Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
struct ContentView: View {
//Whatever scheme you entered in your project settings under URL types
let myURLScheme = "my-scheme://"
@State var text = ""
@State var openedURLs = [String]()
var fullURL: URL {
return URL(unsafeString: myURLScheme + text)
var body: some View {
Form {
HStack {
TextField("Add text to URL", text: $text)
Link(destination: fullURL) {
.onOpenURL { url in
Section(header: Text("Opened URLs")) {
ForEach(0..<openedURLs.count, id: \.self) {
index in Text(openedURLs[index])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment