WebUI is a Swift package that provides WKWebView wrapped by SwiftUI.
- Development with Xcode 15.4+
- Written in Swift 5.9
- Compatible with iOS 16.4+
- Compatible with macOS 13.3+
This library does not collect or track user information, so it does not include a PrivacyInfo.xcprivacy file.
WebUI is available through Swift Package Manager.
Xcode
- File > Add Package Dependencies…
- Search
https://github.com/cybozu/WebUI.git
.
- Add package and link
WebUI
to your application target.
CLI
-
Create
Package.swift
that describes dependencies.// swift-tools-version: 5.9 import PackageDescription let package = Package( name: "SomeProduct", products: [ .library(name: "SomeProduct", targets: ["SomeProduct"]) ], dependencies: [ .package(url: "https://github.com/cybozu/WebUI.git", exact: "2.0.0") ], targets: [ .target( name: "SomeProduct", dependencies: [ .product(name: "WebUI", package: "WebUI") ] ) ] )
-
Run the following command in Terminal.
$ swift package resolve
struct ContentView: View {
var body: some View {
WebViewReader { proxy in
WebView()
.onAppear {
proxy.load(request: URLRequest(url: URL(string: "https://www.example.com")!))
}
}
.padding()
}
}
This repository includes demonstration app for iOS & macOS.
Open Examples/Examples.xcodeproj and Run it.