Add Safari Web Extension support with: - safari_manifest.json for Safari Manifest v3 - make_safari.sh build script using safari-web-extension-converter - BrowserDetect utility for runtime browser detection - SAFARI.md with detailed build and distribution docs - Updated README with Safari instructions - Updated .gitignore for Xcode artifacts https://claude.ai/code/session_01MSpqozazmv9Kaiw9x8kA9M
4.5 KiB
Safari Extension Build Guide
This guide explains how to build and distribute the RYS extension for Safari.
Prerequisites
- macOS - Safari extensions must be built on macOS
- Xcode - Install from the Mac App Store
- Xcode Command Line Tools - Run:
xcode-select --install - Apple Developer Account - Required for distribution ($99/year)
Development Build
Quick Start
./make_safari.sh
This script will:
- Copy the Safari manifest
- Prepare the extension source
- Run
safari-web-extension-converterto create an Xcode project - Output instructions for next steps
Manual Build
If you prefer to build manually:
# 1. Navigate to the src directory
cd src
# 2. Copy the Safari manifest
cp safari_manifest.json manifest.json
# 3. Convert to Safari Web Extension
xcrun safari-web-extension-converter . \
--app-name "RYS - Remove YouTube Suggestions" \
--bundle-identifier "com.lawrencehook.rys" \
--swift \
--macos-only
Testing in Safari
-
Open the Xcode Project
- After running the build script, open the generated
.xcodeprojfile
- After running the build script, open the generated
-
Configure Signing
- Select the project in Xcode's navigator
- Go to "Signing & Capabilities"
- Select your development team
- Xcode will automatically manage signing
-
Build and Run
- Press
Cmd+Ror click the Play button - This builds the app and opens Safari
- Press
-
Enable the Extension
- Open Safari
- Go to Safari > Settings > Extensions
- Check the box next to "RYS - Remove YouTube Suggestions"
- Grant permission to access youtube.com
-
Allow Unsigned Extensions (Development)
- In Safari, enable "Develop" menu: Safari > Settings > Advanced > "Show Develop menu"
- Develop > Allow Unsigned Extensions
- Note: This needs to be re-enabled after each Safari restart
Distribution
Mac App Store
-
Archive the App
- In Xcode: Product > Archive
- Wait for the archive to complete
-
Validate
- In the Organizer window, select the archive
- Click "Validate App"
- Fix any issues reported
-
Distribute
- Click "Distribute App"
- Select "App Store Connect"
- Follow the prompts to upload
-
App Store Connect
- Log in to App Store Connect
- Create a new app listing
- Submit for review
Direct Distribution (Outside App Store)
-
Archive the App
- In Xcode: Product > Archive
-
Export
- Select "Developer ID" distribution
- This requires a paid Apple Developer account
-
Notarize
- Apple requires notarization for apps distributed outside the App Store
- Xcode can handle this automatically during export
-
Distribute
- Share the exported
.appfile - Users will need to right-click and select "Open" the first time
- Share the exported
Safari-Specific Notes
API Compatibility
Safari Web Extensions use the same WebExtensions API as Chrome and Firefox. The RYS extension already includes compatibility shims:
browsernamespace polyfill (Firefox-style API works in Safari)- Dual
browserAction/actionAPI support - Browser detection via
BrowserDetect.isSafari
Known Differences
-
Storage Sync: Safari doesn't support
browser.storage.sync. The extension usesbrowser.storage.localwhich works across all browsers. -
Background Scripts: Safari supports both persistent background pages and service workers. The manifest uses service workers for compatibility.
-
Permissions: Safari may prompt users for permissions differently than Chrome/Firefox.
Troubleshooting
Extension not appearing in Safari:
- Ensure the app is running (check Activity Monitor)
- Check Safari > Settings > Extensions
- Try: Develop > Allow Unsigned Extensions
"App is damaged" error:
- The app needs to be signed
- For development, use:
xattr -cr "/path/to/app.app"
Extension not working on YouTube:
- Verify the extension has permission for youtube.com
- Check Safari > Settings > Extensions > RYS > Website Access
iOS Support (Optional)
To also support iOS/iPadOS:
- When running
safari-web-extension-converter, remove the--macos-onlyflag - In Xcode, add iOS as a deployment target
- The extension will work in Safari on iPhone/iPad
Note: iOS Safari extensions are distributed through the App Store only.
Version Updates
When releasing a new version:
- Update
versioninsafari_manifest.json - Update version in Xcode project settings
- Rebuild and re-submit to the App Store