Load Safari inside app - SwiftUI

Oct 14, 2021 1 min read
Load Safari inside app - SwiftUI

Load Safari as a fullScreenCover inside of your application.

import SwiftUI
import SafariServices
struct SFSafariViewWrapper: UIViewControllerRepresentable {
    let url: URL

    func makeUIViewController(context: UIViewControllerRepresentableContext<Self>) -> SFSafariViewController {
        return SFSafariViewController(url: url)
    }

    func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SFSafariViewWrapper>) {
        return
    }
}
@State private var showSafari: Bool = false
Text("Open Design+Code in Safari")
		.padding()
.onTapGesture {
		showSafari.toggle()
}
.fullScreenCover(isPresented: $showSafari, content: {
		SFSafariViewWrapper(url: URL(string: "https://www.designcode.io")!)
})
Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.