Created
January 28, 2024 08:09
-
-
Save thewh1teagle/0212927f43c4328fe9cbcefed46637f0 to your computer and use it in GitHub Desktop.
Simple swift webview (don't forget to allow outgoing and incoming internet in capabilities settings)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import WebKit | |
struct WebView: NSViewRepresentable { | |
let request: URLRequest | |
func makeNSView(context: Context) -> WKWebView { | |
return WKWebView() | |
} | |
func updateNSView(_ nsView: WKWebView, context: Context) { | |
nsView.load(request) | |
} | |
} | |
struct ContentView: View { | |
var body: some View { | |
WebView(request: URLRequest(url: URL(string: "https://google.com")!)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment