Safari Extensions

Enhance and customize the web browsing experience on Mac, iPhone, and iPad with Safari Extensions

Safari Extensions Documentation

Posts under Safari Extensions tag

215 results found
Post marked as solved
159 Views

After converting a Web Extension using safari-web-extension-converter, running extension fails with SFErrorDomain code 1

I have a web extension https://github.com/david-shortman/clickster In the directory for that extension, I ran david@Davids-Mac-mini clickster % xcrun safari-web-extension-converter . Xcode Project Location: /Volumes/Samsung_T5/dev/GitHub/clickster App Name: Clickster App Bundle Identifier: com.yourCompany.Clickster Language: Swift Is this correct? [yes]: no Xcode Project Location [/Volumes/Samsung_T5/dev/GitHub/clickster]: App Name [Clickster]: App Bundle Identifier [com.yourCompany.Clickster]: com.shortman.Clickster Swift Objective-C Language [1]: 1 Then, Xcode automatically opens that project. I ran the app with the default config for "My Mac". The extension immediately encountered this error in the default guard in ViewController here error error Error? domain: "SFErrorDomain" - code: 1 0x0000600002706ca0 error was thrown on line 3 guard let state = state, error == nil else {                 // Insert code to inform the user that something went wrong.                 return // <- breaks here             }
Asked
Last updated .
Post marked as unsolved
1.1k Views

Crashing on exception: Extension context of class NSExtensionContext has not supplied an auxiliary connection host protocol

Hey, my Safari Extension crashes every so often with the following crash log. I have absolutely no idea why and when it happens, but when it happens once, it crashes instantly when I am trying to reactivate the extension in Safari's settings.Do you have any ideas? Please let me know, if more information could be helpful.Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Illegal instruction: 4 Termination Reason: Namespace SIGNAL, Code 0x4 Terminating Process: exc handler [5197] Application Specific Information: Crashing on exception: Extension context of class NSExtensionContext has not supplied an auxiliary connection host protocol. Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff4ad3ae45 __exceptionPreprocess + 256 1 libobjc.A.dylib 0x00007fff759723c6 objc_exception_throw + 48 2 Foundation 0x00007fff4d08746a -[NSExtensionContext _derivedExtensionAuxiliaryHostProtocol] + 326 3 Foundation 0x00007fff4d087b0a -[NSExtensionContext initWithInputItems:listenerEndpoint:contextUUID:] + 1340 4 Foundation 0x00007fff4d086288 __105-[_NSExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 143 5 libdispatch.dylib 0x00007fff771495f8 _dispatch_call_block_and_release + 12 6 libdispatch.dylib 0x00007fff7714a63d _dispatch_client_callout + 8 7 libdispatch.dylib 0x00007fff7715568d _dispatch_main_queue_callback_4CF + 1135 8 CoreFoundation 0x00007fff4ac854a6 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 9 CoreFoundation 0x00007fff4ac84bd3 __CFRunLoopRun + 2300 10 CoreFoundation 0x00007fff4ac84085 CFRunLoopRunSpecific + 459 11 HIToolbox 0x00007fff49f629db RunCurrentEventLoopInMode + 292 12 HIToolbox 0x00007fff49f6261d ReceiveNextEventCommon + 355 13 HIToolbox 0x00007fff49f624a6 _BlockUntilNextEventMatchingListInModeWithFilter + 64 14 AppKit 0x00007fff482fcffb _DPSNextEvent + 965 15 AppKit 0x00007fff482fbd93 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361 16 ViewBridge 0x00007fff72a6ac43 -[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 99 17 AppKit 0x00007fff482f5eb0 -[NSApplication run] + 699 18 AppKit 0x00007fff482e53f0 NSApplicationMain + 777 19 libxpc.dylib 0x00007fff773ca213 _xpc_objc_main + 612 20 libxpc.dylib 0x00007fff773c9cd9 _xpc_copy_xpcservice_dictionary + 0 21 Foundation 0x00007fff4cf0525a +[NSXPCListener serviceListener] + 0 22 PlugInKit 0x00007fff6d24584b PlugInKit + 84043 23 PlugInKit 0x00007fff6d245693 PlugInKit + 83603 24 PlugInKit 0x00007fff6d245b9f PlugInKit + 84895 25 Foundation 0x00007fff4d1168ac NSExtensionMain + 51 26 libdyld.dylib 0x00007fff771973d5 start + 1 27 ??? 0x0000000000000001 0x0 + 1 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.AppKit 0x00007fff48701767 -[NSApplication _crashOnException:] + 109 1 com.apple.AppKit 0x00007fff48701648 -[NSApplication reportException:] + 916 2 com.apple.AppKit 0x00007fff487c1f09 uncaughtErrorProc + 145 3 com.apple.CoreFoundation 0x00007fff4adaf72d __handleUncaughtException + 775 4 libobjc.A.dylib 0x00007fff75974775 _objc_terminate() + 91 5 libc++abi.dylib 0x00007fff7420a19e std::__terminate(void (*)()) + 8 6 libc++abi.dylib 0x00007fff7420a213 std::terminate() + 51 7 libdispatch.dylib 0x00007fff7714a651 _dispatch_client_callout + 28 8 libdispatch.dylib 0x00007fff7715568d _dispatch_main_queue_callback_4CF + 1135 9 com.apple.CoreFoundation 0x00007fff4ac854a6 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 10 com.apple.CoreFoundation 0x00007fff4ac84bd3 __CFRunLoopRun + 2300 11 com.apple.CoreFoundation 0x00007fff4ac84085 CFRunLoopRunSpecific + 459 12 com.apple.HIToolbox 0x00007fff49f629db RunCurrentEventLoopInMode + 292 13 com.apple.HIToolbox 0x00007fff49f6261d ReceiveNextEventCommon + 355 14 com.apple.HIToolbox 0x00007fff49f624a6 _BlockUntilNextEventMatchingListInModeWithFilter + 64 15 com.apple.AppKit 0x00007fff482fcffb _DPSNextEvent + 965 16 com.apple.AppKit 0x00007fff482fbd93 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361 17 com.apple.ViewBridge 0x00007fff72a6ac43 -[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 99 18 com.apple.AppKit 0x00007fff482f5eb0 -[NSApplication run] + 699 19 com.apple.AppKit 0x00007fff482e53f0 NSApplicationMain + 777 20 libxpc.dylib 0x00007fff773ca213 _xpc_objc_main + 612 21 libxpc.dylib 0x00007fff773c9cd9 xpc_main + 433 22 com.apple.Foundation 0x00007fff4cf0525a -[NSXPCListener resume] + 162 23 com.apple.pluginkit.framework 0x00007fff6d24584b 0x7fff6d231000 + 84043 24 com.apple.pluginkit.framework 0x00007fff6d245693 0x7fff6d231000 + 83603 25 com.apple.pluginkit.framework 0x00007fff6d245b9f 0x7fff6d231000 + 84895 26 com.apple.Foundation 0x00007fff4d1168ac NSExtensionMain + 51 27 libdyld.dylib 0x00007fff771973d5 start + 1
Asked
by mtospr.
Last updated .
Post marked as unsolved
59 Views

Best practices for conducting Unit/UI Testing on Safari App Extensions?

Hi, I have a Safari App Extension that I would like to create unit and UI tests for. I am not new to Swift or development, but admittedly I do not have a lot of experience writing tests. My app extension is in the Mac App Store, so I figured it's the prime candidate for learning. Unfortunately I'm running into issues, namely that the extension doesn't have a host application (or so Xcode thinks), and so the UI tests fail to run: language Cannot test target “TweaksForRedditUITests” on “My Mac”: UITargetAppPath should be provided If I go to the project browser and click on the UI test target, the target application is set to TweaksForReddit, which seems like it's correct. The other targets include TweaksForRedditExtension, TweaksForRedditUnitTests, and TweaksForRedditUITests. I could probably "fudge" it and add a button to the main app's interface that opens the extension's popover view in a window for testing, but I'm mostly wondering if that's necessary. Thanks!
Asked
Last updated .
Post marked as unsolved
197 Views

[bug] Extension frames fail to be embedded on websites

I'm trying to put a view (html page) from a web extension into an iframe on a website. The html file is listed correctly in web&#92;&#95;accessible&#92;&#95;resources, however when I'm trying to load it, I get the following error: Failed to load resource: The operation couldn’t be completed. (Cocoa error -1008.)
Asked
by carlosj.
Last updated .
Post marked as unsolved
132 Views

Web extensions

Safari Web extensions are incredibly slow to open. Is this a bug? Also is there no notification system for extensions?
Asked
by flooie.
Last updated .
Post marked as unsolved
80 Views

Can we create multiple ports by calling connectNative ?

When a let port = chrome.runtime.connectNative('applicationId') is called in Safari Web Extension, does it create multiple ports that can individually communicate with the app extension ? In chrome, every connectNative call spawns one process How does it work in Safari ?
Asked
by sabz19.
Last updated .
Post marked as unsolved
136 Views

Adding Subscription In-App Purchase to Safari Web Extension

I have created a Safari Web Extension, now I want to add Subscription In-App Purchase into this app. Since the Safari Web Extension has two parts: the Mac App and the Extension. I want to ask can I add the IAP codes into the Extension part? So, the Extension can be programmatically enabled or disabled according to the latest subscription status.
Asked
by Code2117.
Last updated .
Post marked as unsolved
152 Views

Could not distribute web extension due to localization error

Hi, I converted my chrome extension to safari web extension. I am trying to distribute this extension to the app store connect, but getting an error regarding my message.json files. For each of my localization files I am getting an error ITMS-90862 The name field must be present, of string type, and 40 or fewer characters long." and The description field must be present, of string type, and 40 or fewer characters long. This is how it is configured in the manifest.json: "name": "__MSG_appName__", "description": "__MSG_appDescription__" I tried adding name and description fields to all of them, but it didn't work. I tried to change my manifest.json name and description entries to be __MSG_name__ and __MSG_description__ and added name and description to the files - and it didn't work. Any ideas? Thanks
Asked
by webdevpro.
Last updated .
Post marked as unsolved
136 Views

Safari Web Extension second launch time slow

Hello, I hope somebody knows how to solve this issue. So I built a Safari Web extension using this tutorial: https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari Basically took other browser build and converted it. Everything works fine except for the application launch start. The first time launch performance is the same like in any other browser but the second launch time always takes more than 1.5sec. At first I though maybe the code inside my extension takes that long to execute but the same performance is with Hello World app. So what have I noticed compared to other browsers is that when you close popup on other browsers the process gets terminated instantly but on safari it gets terminated only on second launch and then it takes more time compared to first launch. Is it Safari default behavior or there is a way to fix this issue?
Asked
by dzimol.
Last updated .
Post marked as unsolved
276 Views

Unexpected Safari Web Extension behavior on mouseover list item in popup

Info: Device: MacBook Pro (16-inch, 2019) macOS Version: 11.1 (20C69) Safari Version: 14.0.2 (16610.3.7.1.9) Xcode Version: 12.3 (12C33) Brief: Mouseover event doesn't work as expected when the extension is in the left side of Safari toolbar, but works well in the left side. You can watch the video for the bug presentation: vimeo.com/502518634 Steps to repeat: Download Chrome Read Later - https://github.com/willbchang/chrome-read-later Run xcrun safari-web-extension-converter chrome-read-later Open Safari -> Develop -> Allow Unassigned Extensions Open chrome-read-later in Xcode and press command + R Open Safari, press Command + , check Read Later Click Read Later icon to allow it on every website Save some tabs with different urls to Read Later by pressing Alt + Shift + S, or right click the webpage and select Read Later Click the the Read Later icon to open the reading list Mouse move through the reading list, you will see the bug 10. Right Click Customize Toolbar in the header of Safari, move the Read Later icon to the right Repeat step 8-9, you'll find the bug is gone
Asked
Last updated .
Post marked as unsolved
155 Views

sendMessage not received by options page onMessage

I have ported a Chrome FireFox extension. One of the things that does not work is receiving message from background to a options page (safari-web-extension://<id>/page.html) I dont get a error message or any details back from the promise. Any idea where this goes wrong? Background: browser.tabs.sendMessage(tab.id, { message }); Options page: browser.runtime.onMessage.addListener(message => { console.log(message); });
Asked
Last updated .
Post marked as unsolved
264 Views

Help fixing localisation for en

ERROR ITMS-90858: "Missing messages file. Safari web extension bundle Pocari/Contents/PlugIns/Pocari.Extension.appex is missing the messages.json file for the en locale." I have this extension that builds and run as expected, but trying to upload it to Apple I get the above error. The messages.json is there for "en" in my locale folder but I must be missing a reference somewhere. I am not trying to build for anything other than English for now. To try to resolve this I have added localisations array with item 0 as English. Where else do I need to look?
Asked
by sloop.
Last updated .
Post marked as unsolved
105 Views

Can the Safari Web Extension talk to Chrome's native messaging host processes?

Is there a way for Safari Web Extensions to talk to the chrome native messaging processes ? Also how does the communication from Safari Web Extension to App Extension happen ? is it using shared memory or sockets ?
Asked
by sabz19.
Last updated .
Post marked as unsolved
123 Views

General questions on Safari Web Extension, App Extension and native

I would like to create multiple App Extension processes from Safari Web Extension by calling the browser.runtime.connectNative API. Would this be feasible? Is there another method to talk to multiple App extension binaries from the Safari Web extension other than using browser.runtime.connectNative Does the Safari Web Extension always need to be bundled with app extension and native app? Can it talk to other app extensions/native app
Asked
by sabz19.
Last updated .