Swiftpack.co -  JakubMazur/SwiftUIWKWebView as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
JakubMazur/SwiftUIWKWebView
WKWebView as NSViewRepresentable for usage in macOS environment and UIViewRepresentable for UIKit
.package(url: "https://github.com/JakubMazur/SwiftUIWKWebView.git", from: "1.0.6")

SwiftUIWKWebView

WKWebView as NSViewRepresentable for usage in macOS environment and UIViewRepresentable for UIKit

Usage

Without ViewModel

Loading a website inside a frame, navigation is possible inside a webpage, but there is no ObservedObject

struct MyWebView: View {
    var body: some View {
        SwiftUIWKWebView(viewModel: .init(urlString: "https://apple.com")!)
    }
}

With ViewModel

extend WebViewModel for more actions from WKNavigationDelegate

struct MyWebView: View {
    @ObservedObject var viewModel: WebViewModel
	
    var body: some View {
        SwiftUIWKWebView(viewModel: viewModel)
    }
}

struct MyWebView_Previews: PreviewProvider {
    static var previews: some View {
        MyWebView(viewModel: .init(urlString: "https://twitter.com/jkmazur")!)
    }
}

GitHub

link
Stars: 0
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

1.0.6
5 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API