{"id":25065479,"url":"https://github.com/cybozu/webui","last_synced_at":"2025-04-05T16:03:24.006Z","repository":{"id":233772697,"uuid":"787790101","full_name":"cybozu/WebUI","owner":"cybozu","description":"WebUI is a Swift package that provides WKWebView wrapped by SwiftUI.","archived":false,"fork":false,"pushed_at":"2025-04-02T10:10:29.000Z","size":310,"stargazers_count":117,"open_issues_count":7,"forks_count":16,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-02T21:43:24.103Z","etag":null,"topics":["ios","macos","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://cybozu.github.io/WebUI/documentation/webui/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cybozu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-17T07:31:19.000Z","updated_at":"2025-03-31T01:09:13.000Z","dependencies_parsed_at":"2024-10-23T08:31:43.238Z","dependency_job_id":"a884c37c-332f-4edd-982d-a625540c36b1","html_url":"https://github.com/cybozu/WebUI","commit_stats":null,"previous_names":["cybozu/webui"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybozu%2FWebUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybozu%2FWebUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybozu%2FWebUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cybozu%2FWebUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cybozu","download_url":"https://codeload.github.com/cybozu/WebUI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361614,"owners_count":20926642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","macos","swift","swiftui"],"created_at":"2025-02-06T19:27:21.390Z","updated_at":"2025-04-05T16:03:23.973Z","avatar_url":"https://github.com/cybozu.png","language":"Swift","readme":"\u003cpicture\u003e\n  \u003csource srcset=\"./Media/logo-dark.svg\" media=\"(prefers-color-scheme: dark)\" alt=\"WebUI by Cybozu\"\u003e\n  \u003cimg src=\"./Media/logo.svg\" alt=\"WebUI by Cybozu\"\u003e\n\u003c/picture\u003e\n\nWebUI is a Swift package that provides WKWebView wrapped by SwiftUI.\n\n[![Github forks](https://img.shields.io/github/forks/cybozu/WebUI)](https://github.com/cybozu/WebUI/network/members)\n[![Github stars](https://img.shields.io/github/stars/cybozu/WebUI)](https://github.com/cybozu/WebUI/stargazers)\n[![Github issues](https://img.shields.io/github/issues/cybozu/WebUI)](https://github.com/cybozu/WebUI/issues)\n[![Github release](https://img.shields.io/github/v/release/cybozu/WebUI)](https://github.com/cybozu/WebUI/releases)\n[![Github license](https://img.shields.io/github/license/cybozu/WebUI)](https://github.com/cybozu/WebUI/blob/main/LICENSE)\n\n## Requirements\n\n- Development with Xcode 16.2+\n- Written in Swift 6.0\n- Compatible with iOS 16.4+\n- Compatible with macOS 13.3+\n\n## Usage\n\nUsing `WebUI`, you can build a WebView in `SwiftUI` with simple APIs.\n\nFor more in-depth infomation, see [API Documentation](https://cybozu.github.io/WebUI/documentation/webui/).\n\n### Display Web Page\n\nUse `WebView(request:)`.\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        WebView(request: URLRequest(url: URL(string: \"https://example.com/\")!))\n    }\n}\n```\n\n### Manipulating WebView\n\nUse `WebViewReader`.Within the scope of `WebViewReader`, you can receive `WebViewProxy`.  \nYou can manipulate `WebView` within the scope of `WebViewReader` via `WebViewProxy`.\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        WebViewReader { proxy in\n            WebView()\n                .onAppear {\n                    proxy.load(request: URLRequest(url: URL(string: \"https://www.example.com\")!))\n                }\n\n            Button(\"Reload\") {\n                proxy.reload()\n            }\n        }\n        .padding()\n    }\n}\n```\n\n### Customizing WebView\n\nUse `WebView(configuration:)`.\n\n```swift\nstruct ContentView: View {\n    let configuration: WKWebViewConfiguration\n\n    init() {\n        configuration = .init()\n        configuration.allowsInlineMediaPlayback = true\n    }\n\n    var body: some View {\n        WebView(configuration: configuration)\n    }\n}\n```\n\nOther useful APIs are available.\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        WebView()\n            .allowsLinkPreview(true)\n            .refreshable()\n    }\n}\n```\n\n### Using with Delegates\n\nUse `uiDelegate(_:)`, `navigationDelegate(_:)` method.\n\n```swift\nfinal class MyUIDelegate: NSObject, WKUIDelegate {}\n\nfinal class MyNavigationDelegate: NSObject, WKNavigationDelegate {}\n\nstruct ContentView: View {\n    var body: some View {\n        WebView()\n            .uiDelegate(MyUIDelegate())\n            .navigationDelegate(MyNavigationDelegate())\n    }\n}\n```\n\n## Documentation\n\n[Latest (Swift-DocC)](https://cybozu.github.io/WebUI/documentation/webui/)\n\n## Installation\n\nWebUI is available through [Swift Package Manager](https://github.com/apple/swift-package-manager/).\n\n**Xcode**\n\n1. File \u003e Add Package Dependencies…\n2. Search `https://github.com/cybozu/WebUI.git`.  \n   \u003cimg src=\"./Media/add-package-dependencies.png\" width=\"800px\"\u003e\n3. Add package and link `WebUI` to your application target.  \n   \u003cimg src=\"./Media/add-package.png\" width=\"600px\"\u003e\n\n**CLI**\n\n1. Create `Package.swift` that describes dependencies.\n\n   ```swift\n   // swift-tools-version: 6.0\n   import PackageDescription\n\n   let package = Package(\n       name: \"SomeProduct\",\n       products: [\n           .library(name: \"SomeProduct\", targets: [\"SomeProduct\"])\n       ],\n       dependencies: [\n           .package(url: \"https://github.com/cybozu/WebUI.git\", exact: \"3.0.0\")\n       ],\n       targets: [\n           .target(\n               name: \"SomeProduct\",\n               dependencies: [\n                   .product(name: \"WebUI\", package: \"WebUI\")\n               ]\n           )\n       ]\n   )\n   ```\n\n2. Run the following command in Terminal.\n   ```sh\n   $ swift package resolve\n   ```\n\n## Privacy Manifest\n\nThis library does not collect or track user information, so it does not include a PrivacyInfo.xcprivacy file.\n\n## Demo\n\nThis repository includes demonstration app for iOS \u0026 macOS.\n\nOpen [Examples/Examples.xcodeproj](/Examples/Examples.xcodeproj) and Run it.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybozu%2Fwebui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcybozu%2Fwebui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybozu%2Fwebui/lists"}