HACKER Q&A
📣 captn3m0

Can Safari extensions for iOS work in other browsers?


Not an iOS developer, but I’m not sure if this is a technical limitation imposed by Apple, or if there hasn’t been a better effort. Apple’s webview HIG docs say:

> Avoid using a web view to build a web browser. Using a web view to let people briefly access a website without leaving the context of your app is fine, but Safari is the primary way people browse the web on iOS. Attempting to replicate the functionality of Safari in your app is unnecessary and discouraged.

So I guess Appple didn’t really mean it when they started supporting a default browser on iOS.

All of the Extension talks only mention Safari, but maybe there is a way?

[0]: https://developer.apple.com/design/human-interface-guidelines/ios/views/web-views/


  👤 efortis Accepted Answer ✓
Desktop Safari extensions work pretty well in Chrome. Keep in mind that Safari uses manifest v2, while Chrome v3, so you'll need two different manifests.

iOS Safari has some limitations [1], e.g.

1. the time it can run the background script.

2. you need to use the Alarm API (minute resolution) instead of `setTimeout`

3. no support for `contextMenus`, so you'll have to make your own.

If you need `executeScript` in Safari:

    if (typeof chrome.scripting === "undefined")
      chrome.scripting = {
        executeScript: ({ files, target }) =>
          browser.tabs.executeScript(target.tabId, { file: files[0] })
      }

[1] https://developer.apple.com/documentation/safariservices/saf...

👤 Daedren
It’s a set limitation. It’s the same thing as the Content Blocker apps that also don’t work on other browsers.

They really don’t want you to use anything other than Safari