It's not "baked in to Swift", but you can use standard UIKit
methods to do it. Take a look at UIApplication's openUrl(_:)
(deprecated) and open(_:options:completionHandler:)
.
Swift 4 + Swift 5 (iOS 10 and above)
guard let url = URL(string: "https://stackoverflow.com") else { return }
UIApplication.shared.open(url)
Swift 3 (iOS 9 and below)
guard let url = URL(string: "https://stackoverflow.com") else { return }
UIApplication.shared.openURL(url)
Swift 2.2
guard let url = URL(string: "https://stackoverflow.com") else { return }
UIApplication.sharedApplication().openURL(url)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…