Skip to content

RFC: Official End-to-End Safari Extension Support (@wxt-dev/module-safari + publish-browser-extension) #2776

Open

Description

@rxliuli

Related discussions: aklinker1/publish-browser-extension#65, aklinker1/publish-browser-extension#89
Reference implementation: rxliuli/extport (running in production across 20+ macOS & iOS Safari extensions)


Summary

Following up on the Safari support discussion in aklinker1/publish-browser-extension#89, this RFC proposes official, end-to-end Safari Web Extension support spanning both build (wxt-dev/wxt) and publish (publish-browser-extension).

Core design principles for v1:


Background & Motivation

Unlike Chrome, Firefox, and Edge — where a single .zip is uploaded to a store API — shipping a Safari Web Extension involves 4 distinct stages:

  1. Convert & Normalize (macOS): Convert the built web extension into an Xcode project (.xcodeproj) with normalized bundle IDs, versions, metadata, and a host-app setup UI.
  2. Archive & Sign (macOS): Build and sign the macOS and/or iOS targets from the .xcodeproj.
  3. Upload Binary (macOS): Upload the signed build to App Store Connect (cannot be done via the ASC REST API).
  4. Submit for Review (REST API): Wait for Apple to finish processing the uploaded build, create/adopt an App Store version, attach the build, and submit it for App Review.

Because Stage 1 belongs to the build phase and Stages 2–4 belong to the publishing phase, this requires coordinated design across wxt-dev/wxt and publish-browser-extension.


Architecture & Ownership Split

Stage Command Runs on Owner
1. Convert & Normalize wxt build -b safari macOS @wxt-dev/module-safari (private package bundled into wxt)
2. Archive & Sign wxt submit macOS publish-browser-extension (SafariAddonStore)
3. Upload Binary wxt submit macOS publish-browser-extension (SafariAddonStore)
4. Submit for Review wxt submit (skipped with --skip-submit-review) Any OS (ASC REST API) publish-browser-extension (SafariAddonStore)
flowchart LR
    A["wxt build -b safari"] -->|"Stage 1: @wxt-dev/module-safari"| B[".output/<ProjectName>/<ProjectName>.xcodeproj"]
    B -->|"Stages 2 & 3: xcodebuild archive + exportArchive (upload)"| C["App Store Connect Build"]
    C -->|"Stage 4: ASC REST API (unless --skip-submit-review)"| D["Submitted for App Review"]
Loading

Stage 1: @wxt-dev/module-safari (wxt build -b safari)

Implemented as a private workspace package (@wxt-dev/module-safari) inside wxt-dev/wxt and bundled directly into wxt at release time, so wxt build -b safari works out of the box with zero extra package installation.

Runs on WXT's build:done hook when browser === 'safari' (macOS only), wrapping xcrun safari-web-extension-converter and handling the real-world edge cases encountered in production:

1. Xcode Project Normalization

  • Both Xcode project formats: Handles both legacy OpenStep project.pbxproj (read via plutil -convert json, avoiding brittle regex parsing) and Xcode 27.2+'s JSON project.xcproj.
  • Reliable Bundle ID resolution: safari-web-extension-converter does not consistently honor --bundle-identifier across Xcode versions and --macos-only/--ios-only flags. Bundle IDs are resolved by target productType (application → <bundleId>, app-extension → <bundleId>.Extension).
  • Version & metadata stamping: Syncs MARKETING_VERSION and CURRENT_PROJECT_VERSION from package.json / manifest, sets LSApplicationCategoryType, ITSAppUsesNonExemptEncryption = NO, DEVELOPMENT_TEAM, and CFBundleVersion in Info.plist.

2. Zero-Config Host App Setup Page

In aklinker1/publish-browser-extension#89, @aklinker1 raised the question of whether the generated host app UI needs customization.

Apple's default converter template is too bare — especially on iOS (Settings → Apps → Safari → Extensions). Since the enabling flow is the same for every Safari extension, @wxt-dev/module-safari replaces the generated Main.html/Style.css/Script.js with a clean, universal setup guide:

  • macOS: Extension enabled status badge (via the converter's existing SFSafariExtensionManager hook), 4-step guide, and the "Open Safari Settings…" button, with a widened window so nothing clips.
  • iOS: 4-step guide through Settings and the Safari address bar extension button.
  • Zero config: Uses the extension name from the manifest, leaves generated Swift untouched, and handles both single-platform (flat) and universal (Shared (App)) layouts.

Configuration (wxt.config.ts)

Platform selection (macos, ios, or both) lives in wxt.config.ts, which directly determines what Xcode targets/schemes Stage 1 generates:

export default defineConfig({
  safari: {
    bundleIdentifier: 'com.example.my-extension',
    appCategory: 'public.app-category.productivity',
    developmentTeam: 'ABC1234567',
    projectType: 'both', // 'macos' | 'ios' | 'both' (default: 'both')
  },
})

Stages 2–4: publish-browser-extension (wxt submit)

Adds a SafariAddonStore that takes the Xcode project directory generated by Stage 1 and runs Stages 2–4 end-to-end.

Stages 2 & 3: Archive, Sign & Upload (xcodebuild only)

  • Auto-detects platforms (macos, ios, or both) directly from the generated Xcode project's schemes via xcodebuild -list -json — controlled by safari.projectType in wxt.config.ts, with no extra platform flags needed at submit time.
  • Single-pass archive + export/upload per detected platform:
    1. xcodebuild archive with CODE_SIGN_STYLE=Automatic, -allowProvisioningUpdates, and App Store Connect API key flags (-authenticationKeyID, -authenticationKeyIssuerID, -authenticationKeyPath).
    2. xcodebuild -exportArchive with method: app-store-connect, signingStyle: automatic, and destination: upload.
  • Why xcodebuild -exportArchive (destination: upload) instead of altool?
    • It is Apple's current recommended replacement for deprecated altool.
    • Automatic signing handles both the host .app and nested Safari .appex in one pass — no manual codesign, productbuild, or provisioning profile files required.
    • One unified path: no .pkg/.ipa special-casing or duplicate upload code to maintain.
  • API Key discovery: Supports explicit key path as well as Apple's conventional lookup directories (./private_keys, ~/private_keys, ~/.private_keys, ~/.appstoreconnect/private_keys).
  • CI Signing Caveat (documented & solved): Ephemeral CI runners (e.g. GitHub Actions macos-latest) start with an empty keychain. Calling -allowProvisioningUpdates with an empty keychain causes Apple to mint a brand new distribution certificate on every run until the account hits Apple's certificate cap. Our CI docs will cover importing a single reusable .p12 certificate into a temporary keychain before running wxt submit.

Stage 4: Wait for Processing & Submit for Review (ASC REST API)

Uploading a binary only places it in App Store Connect's build list — it does not create a release or submit for App Review.

Matching publish-browser-extension's existing behavior for Chrome, Firefox, and Edge:

  • Default (full submit):
    1. Authenticates to https://api.appstoreconnect.apple.com with an ES256 JWT signed by the same .p8 API key (no extra credentials needed).
    2. Polls /v1/builds until the uploaded build for (version, platform) reaches processingState: VALID.
    3. Creates or adopts the platform's editable appStoreVersion (idempotently handling PREPARE_FOR_SUBMISSION, REJECTED, or superseded drafts).
    4. Attaches the build and populates a default "What's New" note if empty (required by Apple).
    5. Submits for review via the reviewSubmissions API.
  • --skip-submit-review: Stops after Stage 3 (binary uploaded to ASC, no version created or submitted for review).

Explicit Non-Goals for v1 (and Future Work)

To keep v1 focused, minimal, and maintainable:

  • No prebuilt .pkg/.ipa upload mode or custom entry points in v1: One canonical flow (.xcodeproj → xcodebuild → ASC).
  • No host-app localization in v1: Automatically generating <lang>.lproj/InfoPlist.strings and localized setup pages from public/_locales/* is planned as a post-v1 enhancement once the core pipeline is stable.
  • No custom native host-app builder: Projects that need a custom Swift/SwiftUI host app should manage their own Xcode/Fastlane setup rather than turning WXT into a native app build system.
  • First-time App Store Connect app creation remains manual: The ASC API does not support creating a brand-new App record; this is a one-time manual step documented in the setup guide.
  • macOS required for Safari builds & uploads: Stages 1–3 rely on Apple's Xcode CLI tools (safari-web-extension-converter, xcodebuild).

Implementation Plan & Maintenance

All core pieces are already proven in rxliuli/extport (packages/wxt, packages/cli/src/safari-build.ts, packages/store-adapters/src/safari.ts):

  1. Stage 1 (wxt-dev/wxt): Implement @wxt-dev/module-safari (private package bundled into wxt) with Xcode project normalization (.pbxproj + .xcproj) and the zero-config setup page.
  2. Stages 2–4 (publish-browser-extension): Implement SafariAddonStore (archive/sign/upload via xcodebuild, plus ASC REST API submission with --skip-submit-review).
  3. Verification & Docs: End-to-end test against a real App Store Connect app (macOS + iOS) and publish a CI guide (including reusable .p12 certificate setup for GitHub Actions).

I'm committed to driving this implementation and continuing to maintain Safari build and publishing support in WXT and publish-browser-extension long-term (including keeping up with annual Xcode changes).


Feedback Requested

@aklinker1 — before I open PRs across wxt-dev/wxt and publish-browser-extension, I'd love your confirmation on:

  1. Bundling @wxt-dev/module-safari as an internal/private package directly in wxt (and exposing the safari config key in wxt.config.ts).
  2. The single-path v1 scope (wxt build -b safari → wxt submit, with --skip-submit-review to stop after upload).
  3. Any naming, CLI flag, or docs conventions you'd like us to follow across both repos.

Activity

  1. rxliuli commented on Nov 23, 2026

    @rxliuli
    ContributorAuthor

    Update: I've built a working end-to-end prototype of both halves (Stage 1 in wxt and Stages 2–4 in publish-browser-extension) and verified the full flow against a real App Store Connect app (macOS + iOS submitted and confirmed WAITING_FOR_REVIEW).

    Here is a runnable demo branch using packed tarballs of both branches:

    I'll follow up with PRs for both repos shortly.

  2. rxliuli commented on Nov 23, 2026

    @rxliuli
    ContributorAuthor

    Verified on a clean GitHub Actions macos-26 runner as well (building with @wxt-dev/module-safari from #2779, importing a reusable .p12 cert into a temporary keychain, and uploading macOS + iOS v0.0.24 via wxt submit --safari-skip-submit-review from aklinker1/publish-browser-extension#99):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions