With SwiftUI 2 you can open URLs with the new Link structure. You can also open URLs in-app with a SFSafariViewController . But maybe you want to give the user the choice, if he wants the link to be opened in-app, in Safari or even in other browsers like Google Chrome, Firefox or Opera.


Browser selection

The selection will be stored in UserDefaults . If you only want to give the user two options, you can use a Bool value, if you want multiple use Int .

// Put this before the body var of your settings view
	@AppStorage("LinkDestination") var linkDestination = 0

	// Put this inside your view
	Picker("Open links", selection: $linkDestination) {
	    Text("In-App").tag(0)
	    Text("Safari").tag(1)
	}

#browsers #swift #swiftui #google

Open URLs in your SwiftUI app and let the user change the browser.
4.40 GEEK