swiftship/internal/skills/data/features/safari-extension/SKILL.md
Safari Web Extension integration with content scripts, background service workers, native messaging via SFSafariExtensionHandler, and manifest v3 configuration. Use when adding a Safari browser extension target to an iOS or macOS app.
npx skillsauth add abdullah4ai/apple-developer-toolkit safari-extensionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Safari Web Extensions use web technologies (JS/HTML/CSS) plus a native Swift wrapper for browser integration. The extension runs as a separate target alongside the main app.
Requires a separate extension target configured as kind: "safari" in the plan extensions array.
Implement SFSafariExtensionHandler for bidirectional messaging between Swift and JavaScript:
import SafariServices
class SafariExtensionHandler: SFSafariExtensionHandler {
override func toolbarItemClicked(in window: SFSafariWindow) {
window.getActiveTab { tab in
tab?.getActivePage { page in
page?.dispatchMessageToScript(withName: "buttonClicked", userInfo: [:])
}
}
}
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
// Handle messages sent from JS via browser.runtime.sendNativeMessage()
}
}
Set these keys in the extension target's Info.plist (via XcodeGen):
NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).SafariExtensionHandler
NSExtensionAttributes:
SFSafariWebsiteAccess: { Level: All }
Place these files in the extension bundle:
manifest.json — Web Extension manifest v3background.js — service worker for background logiccontent.js — injected into web pages for DOM accesspopup.html — toolbar popup UI (optional)The user must manually enable the extension in Safari → Settings → Extensions before it becomes active.
testing
Use for 3D games: racing, 3D sports, board games, marble maze, tower defense, bowling. SceneKit + SceneView architecture, 3D scene hierarchy, physics, game loop, primitives, materials, cameras, particles, audio.
documentation
Game UI patterns: SwiftUI HUD overlays on SpriteKit, menus (main/pause/game-over), virtual joystick/d-pad, score displays, health bars, tutorial onboarding.
tools
Download free game sprites/textures/3D models and generate procedural assets. Covers nw_download_asset tool, texture factories, sprite atlas organization, 3D model loading, and programmatic asset creation.
testing
Use for 2D games: arcade, puzzle, sports, ping pong, platformer, shooter, 2D racing. SpriteKit + SpriteView architecture, scene hierarchy, physics, game loop, audio, particles, game feel.