본문으로 건너뛰기
cccskills
무료GitHub에 공개

webkit-integration

WebKit integration in SwiftUI using WebView and WebPage for embedding web content, navigation, JavaScript interop, and customization. Use when embedding web content in SwiftUI apps.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(4)

  • SKILL.md5.9 KB
  • javascript-advanced.md12.7 KB
  • navigation.md12.8 KB
  • webview-basics.md8.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

WebKit Integration for SwiftUI

Embed and control web content in SwiftUI apps using the native WebView struct and WebPage observable class. Covers loading, navigation, JavaScript execution, and view customization.

When This Skill Activates

  • User wants to display web content inside a SwiftUI app
  • User needs to load URLs, HTML strings, or data blobs in a web view
  • User asks about JavaScript interop from SwiftUI
  • User needs navigation control (back, forward, reload) for embedded web content
  • User wants to customize web view behavior (gestures, text selection, link previews)
  • User needs to capture snapshots or export PDFs from web content
  • User asks about intercepting navigation requests or custom URL schemes
  • User wants to configure private browsing or custom user agents

Decision Tree

What do you need?
|
+-- Display a URL or HTML content
|   +-- Simple, no interaction needed
|   |   +-- WebView(url:) --> see webview-basics.md
|   +-- Need loading state, reload, custom config
|       +-- WebPage + WebView(page) --> see webview-basics.md
|
+-- Navigate programmatically (back, forward, intercept)
|   +-- Back/forward list, navigation events
|   |   +-- see navigation.md
|   +-- Intercept or cancel navigation requests
|       +-- NavigationDeciding protocol --> see navigation.md
|
+-- Execute JavaScript or communicate with web content
|   +-- callJavaScript, arguments, content worlds
|       +-- see javascript-advanced.md
|
+-- Capture snapshots, export PDF, web archive
|   +-- page.snapshot(), page.pdf(), page.webArchiveData()
|       +-- see javascript-advanced.md
|
+-- Handle custom URL schemes
    +-- URLSchemeHandler protocol --> see javascript-advanced.md

API Availability

APIMinimum OSImport
WebViewiOS 26 / macOS 26SwiftUI + WebKit
WebPageiOS 26 / macOS 26WebKit
WebPage.ConfigurationiOS 26 / macOS 26WebKit
NavigationDecidingiOS 26 / macOS 26WebKit
WKContentWorldiOS 14 / macOS 11WebKit
WKSnapshotConfigurationiOS 11 / macOS 10.13WebKit
WKPDFConfigurationiOS 14 / macOS 11WebKit

Quick Start

Simplest Usage

import SwiftUI
import WebKit

struct BrowserView: View {
    var body: some View {
        WebView(url: URL(string: "https://developer.apple.com")!)
    }
}

With WebPage for Full Control

import SwiftUI
import WebKit

struct ControlledBrowserView: View {
    @State private var page = WebPage()

    var body: some View {
        WebView(page)
            .onAppear {
                page.load(URLRequest(url: URL(string: "https://developer.apple.com")!))
            }
    }
}

Top Mistakes

MistakeProblemFix
Using WebView(url:) when you need navigation controlNo access to back/forward, reload, or eventsUse WebPage + WebView(page)
Forgetting import WebKit alongside import SwiftUIWebView is in SwiftUI but WebPage requires WebKitAlways import both
Not observing currentNavigationEventMissing loading states, errors go unnoticedUse onChange(of: page.currentNavigationEvent)
Calling callJavaScript before page finishes loadingScript fails because DOM is not readyWait for .finished navigation event
Using persistent data store for private browsingUser data is saved to diskUse .nonPersistent() on WebsiteDataStore
Not handling nil return from decidePolicyFor(navigationAction:)Navigation proceeds when it should be cancelledReturn nil to cancel, return NavigationPreferences to allow
Passing JavaScript without argument bindingVulnerable to injection, hard to debugUse arguments: parameter for named values

Review Checklist

  • Using WebPage when any control beyond simple display is needed
  • Both SwiftUI and WebKit are imported
  • Navigation events observed for loading indicators and error handling
  • JavaScript execution waits for page to finish loading
  • Private browsing uses .nonPersistent() data store
  • Navigation interception returns correct values (preferences to allow, nil to cancel)
  • JavaScript arguments passed via arguments: parameter, not string interpolation
  • Custom URL scheme handler registered on configuration before page loads
  • Find-in-page enabled with findNavigator(isPresented:) if needed
  • Appropriate gesture and interaction modifiers applied (back/forward, magnification, text selection)
  • Content background customized if needed for visual integration

Reference Files

FileContents
webview-basics.mdWebView creation, WebPage setup, configuration, find-in-page, customization modifiers
navigation.mdLoading content, back/forward list, navigation events, NavigationDeciding protocol
javascript-advanced.mdJavaScript execution, content worlds, snapshots, PDF export, custom URL schemes

Cross-References

  • For macOS window management around web views, see macos/architecture-patterns/
  • For navigation architecture that hosts a web view, see ios/navigation-patterns/
  • For Liquid Glass design around web content, see design/liquid-glass/

References

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Run a structured accessibility audit on an iOS/macOS app — automated XCUITest audits, Accessibility Inspector, manual VoiceOver/Dynamic Type passes, and App Store Accessibility Nutrition Label evaluation. Use before release, when preparing Nutrition Label declarations, or for EU Accessibility Act compliance.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

Generate accessibility infrastructure for VoiceOver, Dynamic Type, and accessibility features. Use when improving app accessibility, adding accessibility labels and hints, or auditing compliance.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

Generates an Apple-compliant account deletion flow with multi-step confirmation UI, optional data export, configurable grace period, Keychain cleanup, and server-side deletion request. Use when user needs account deletion, right-to-delete, or Apple App Review compliance for account removal.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

Privacy-preserving ad measurement with AdAttributionKit (SKAdNetwork's successor) — install and re-engagement attribution, conversion-value strategy under crowd anonymity, and end-to-end postback testing. Use when running paid acquisition beyond Apple Ads, measuring re-engagement campaigns, designing conversion values, or migrating from SKAdNetwork.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

alarmkit

무료

AlarmKit integration for scheduling alarms and timers with custom UI, Live Activities, and snooze support. Use when implementing alarm or timer features in iOS 26+ apps.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

Interpret app metrics and make data-driven decisions. Covers DAU/MAU, retention, LTV, ARPU, App Store Connect analytics, AARRR funnel analysis, cohort analysis, and diagnostic decision trees. Use when user wants to understand their metrics, diagnose problems, or build a data-driven growth plan.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rshankras/claude-code-apple-skills8132026년 7월 24일 업데이트

rshankras의 스킬 모두 보기

이 스킬의 문제 신고