Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 3 min read How-to mediumAdept

Building Profiles with new WebKit API

macOS 14 and iOS 17 add WebKit APIs for creating multiple persistent WKWebsiteDataStore instances, each keyed by a UUID, so apps can build browser-style profiles with separate cookies and website data. Assign a store to a WKWebView through its configuration, remove it with WKWebsiteDataStore.remove(forIdentifier:), which can fail if the store is in use or the file system errors, and list existing stores via allDataStoreIdentifiers to avoid creating one by accident. App-owned data such as bookmarks, history and per-site settings still has to be separated per profile by the client.

Assumes: WKWebView basicsSwift async/await

Related posts

  • The File System API with Origin Private File System

    WebKit mediumAdept

    WebKit now supports the File System Standard's origin private file system, a per-origin sandboxed storage area where web apps can create, read, write, move, enumerate and delete files and directories. It is available from Safari on macOS 12.2 and iOS 15.2, has the same lifetime as IndexedDB and localStorage, and is disabled in Private Browsing. Worked examples cover navigator.storage.getDirectory(), getFileHandle/getDirectoryHandle, move(), resolve(), async iteration, removeEntry() and getFile(). Writing in WebKit currently requires FileSystemSyncAccessHandle, which works only in Workers, takes exclusive access to a file, and offers synchronous read, write, truncate and flush for the best performance.

  • Global Privacy Control (GPC) WebKit API

    WebKit mediumAdept

    iOS, iPadOS, visionOS and macOS 27 add a WebKit API that lets apps embedding WKWebView or SwiftUI's WebPage opt navigations into Global Privacy Control, the emerging standard for signalling opt-out of data sharing and cross-context targeted advertising (recognized under California's CCPA). Setting `globalPrivacyControlEnabled` on the WKWebpagePreferences returned from the navigation-policy delegate, or `isGlobalPrivacyControlEnabled` on WebPage.NavigationPreferences, enables `navigator.globalPrivacyControl` and the `Sec-GPC: 1` header for the main frame, subframes and subresources. Example delegate code is given in Swift and Objective-C so apps can wire GPC to their own user setting.

  • News from WWDC23: WebKit Features in Safari 17 beta

    WebKit mediumAdept

    Safari 17 beta brings 88 web features. Mac users can add any website to the Dock as a web app: cookies are copied over and web push and badging are supported. The release also adds experimental <model> and WebXR (immersive-vr with hand tracking) for Vision Pro, JPEG XL and HEIC image support, image-set() type arguments, and the power-efficient Managed Media Source API for adaptive streaming. HTML gains the popover attribute and <hr> in <select>, CSS gains @counter-style and expanded font-size-adjust, and each feature comes with code examples showing usage and fallbacks.

  • WebKit Features in Safari 16.0

    WebKit easyNovice

    Safari 16.0 ships AVIF images on iOS, passkeys built on WebAuthn, CSS Container Queries (size queries and cq* units), Subgrid, Offset Path animation, overscroll-behavior, Shared Workers, and Web Inspector Extensions, plus a new Flexbox Inspector. A re-architected macOS accessibility layer (Isolated Tree Mode) moves work off the main thread, serving twice as many requests in 25% less time on complex pages. Sites adopting passkeys should avoid tying sign-in to the device that saved the key and should enable conditional mediation for AutoFill. The release also includes many form, CSP and Web Inspector fixes.

  • News from WWDC24: WebKit in Safari 18 beta

    WebKit mediumAdept

    Safari 18 beta ships 48 new web platform features, 18 deprecations and 174 bug fixes across iOS 18, iPadOS 18, visionOS 2 and macOS Sequoia betas. Headline additions include immersive WebXR on visionOS with transient-pointer input and hand tracking, the View Transitions API, CSS Style Queries for custom properties, and currentcolor and system color keywords in Relative Color Syntax. Further additions are display-property transitions, the safe alignment keyword in Flexbox, content-visibility, and unprefixed backdrop-filter. Mac web apps can now open matching links based on their manifest scope and support extensions, and the Fullscreen API on visionOS can present spatial photos and panoramas immersively.

The quest for software engineering knowledge.

Look:
Layout: