wxt-module-safari-xcode
v0.2.2
Published
A WXT module that automatically converts Safari extensions to Xcode projects
Maintainers
Readme
Safari Xcode Module
A WXT module that automatically converts Safari extensions to Xcode projects and configures related settings after the build is complete.
https://github.com/user-attachments/assets/4e7d425c-7c9b-4e24-bcea-185cde36b049
Features
- Automatically runs
xcrun safari-web-extension-converterto convert the extension to an Xcode project - Updates Xcode project configuration (version number, app category, development team, etc.)
- Updates all Info.plist files
Usage
1. Enable the module in wxt.config.ts
import { defineConfig } from 'wxt'
export default defineConfig({
modules: ['wxt-module-safari-xcode'],
safariXcode: {
projectName: 'Your Project Name',
appCategory: 'public.app-category.productivity',
bundleIdentifier: 'com.example.your-extension',
developmentTeam: 'ABC1234567',
},
// ... other configurations
})2. Build Safari Extension
pnpm wxt build -b safariThe module will automatically convert the extension to an Xcode project after the build completes.
Configuration Options
| Option | Type | Required | Description |
| ------------------ | -------- | :------: | --------------------------------------------------------------------------------------------- |
| projectName | string | ❌ | Safari project name. Falls back to manifest.name, then to the name field in package.json |
| appCategory | string | ✅ | App category, e.g., 'public.app-category.productivity' |
| bundleIdentifier | string | ✅ | Bundle identifier, e.g., 'com.example.app' |
| developmentTeam | string | ❌ | Apple Developer Team ID, e.g., 'ABC1234567'. If not provided, must be set manually in Xcode |
| outputPath | string | ❌ | Custom output path for the Xcode project. Defaults to .output/<projectName> |
| projectType | string | ❌ | Project type: 'macos', 'ios', or 'both'. Defaults to 'both' |
| openProject | boolean| ❌ | Whether to open the Xcode project after conversion. Defaults to true |
How It Works
This module uses WXT's build:done hook to perform the following steps after the build completes:
- Run
xcrun safari-web-extension-converterto convert the extension to a Safari Xcode project - Read the version number from
package.json - Update the Xcode project configuration file (
.xcodeproj/project.pbxproj)- Set
MARKETING_VERSIONto the version from package.json - Set
CURRENT_PROJECT_VERSIONto numeric version (major _ 10000 + minor _ 100 + patch) - Configure app category
- Configure development team (if provided)
- Set
- Update all Info.plist files and add
CFBundleVersion
Notes
- This module only executes when building for Safari browser (
wxt build -b safari) - Supports both MV2 and MV3 Safari builds (the build target is detected from
wxt.config.manifestVersion) - Requires macOS and Xcode Command Line Tools
- If you want to read configuration from environment variables, ensure
.env.localis added to.gitignore
Examples
Complete Configuration Example
import { defineConfig } from 'wxt'
export default defineConfig({
modules: ['@wxt-dev/module-react', 'wxt-module-safari-xcode'],
safariXcode: {
projectName: 'My Awesome Extension',
appCategory: 'public.app-category.productivity',
bundleIdentifier: 'com.mycompany.awesome-extension',
developmentTeam: 'ABC1234567',
},
manifest: {
name: 'My Awesome Extension',
version: '0.1.0',
},
})Generate the Xcode project will be located at: .output/<projectName>/<projectName>.xcodeproj
