Safari Web Extension errors "SFErrorDomain Code=1"

Hello dear Apple Community,
I'm pretty new to this, so probably this is a simple fix...
I just created a Safari Web Extension from the "official" template in Xcode (File > New > Project > Safari Extension App). I ran it an it popped a window open which has a button that says something like "Quit and open Safari Preferences".
I press it and nothing happens. Weirdly though, a week ago, I tried pretty much the same -> worked perfectly. But now it doesn't. So I made the button press event look like this: 
Code Block swift
@IBAction func openSafariExtensionPreferences(_ sender: AnyObject?) {
SFSafariApplication.showPreferencesForExtension(withIdentifier: extensionBundleIdentifier) { error in
            guard error == nil else {
                print(error.debugDescription)
                return
            }
            DispatchQueue.main.async {
                NSApplication.shared.terminate(nil)
            }
        }
    }

And it printed me out this error: 

(Error Domain=SFErrorDomain Code=1 "(null)")

I checked "Allow Unsigned Extensions" and even tried it with the "Sea Creator" Example code found here and some other Safari Web Extensions that I wrote a week ago. They all seem to throw the same error. I guess it could be a corrupted file or something - about that: yup, I already restarted my Mac. Is there a way to "reinstall" Safari without restoring my entire machine?

What am I missing? Afaik the error means that my extension wasn't found or that I'm not the owner, but how could that be... because why would Xcode give me an invalid template and why would it have worked then a week ago? I'm just confused.


Thanks in advance! :)

Answered by M4GG1 in 655938022
Ok small update: Everything works now. I don't know why, I just restarted my Mac. I'm still confused. Maybe someone knows why on gods green earth that happened. (?)

Accepted Answer
Ok small update: Everything works now. I don't know why, I just restarted my Mac. I'm still confused. Maybe someone knows why on gods green earth that happened. (?)

I had this problem as well but restarting did not help. I found this fix in a GitHub issue thread that worked for me right away. Run this in the Terminal to get Safari to re-register with LaunchServices:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Safari.app

Source: https://github.com/ovity/octotree/issues/1110 More on lsregister (it's not currently documented in man): https://ss64.com/osx/lsregister.html

Safari Web Extension errors "SFErrorDomain Code=1"
 
 
Q