Safari app extension not detected in showPreferencesForExtension

I'm building an Safari app extension with a main view with a button to enable the extension in safari preferences.

The button uses this code:


SFSafariApplication.showPreferencesForExtension(withIdentifier: "com.bry.*****.*****1") { (error) in

     if error != nil {

          print("Error launching the extension's preferences: %@", error);

          return;

     }     

}


"com.bry.*****" is the bundle ID and "com.bry.*****.*****1" is the extension bundle ID


The thing is, this code works in my Mac OSX wich version is = 10.13.1 I just send it to another friend with the same OS and it works as well.


BUT, I send it to another 2 friends that uses 10.12.6 (Sierra) and doesn't work.

The code print this error: Optional(Error Domain=SFErrorDomain Code=1 "(null)")


I think it means that the extension id doesn't exist, but in another topic someone says that this is related to the extension owner or something.

I can't figure out why it does work in 10.13 and not in 12.6, safariServices are supported by 12+ OS.

Any hints?

The error you are seeing appears to be SFErrorNoExtensionFound - which means that on the machines running 10.12.6, they are unable to find your extension.


A few questions:

1) Is the app you are trying to distribute signed using a Mac App Store or Devloper ID certificate?

2) If the users who are failing to use the API opens Safari's preferences, do they see your extension in there?

I'm having the same problem, it works on 10.13 but not 10.12.


1) Developer ID

2) Yes, the extension is in Safari Preferences


Also I'm seeing this bizarre behavior where the ".appex" file extension does not appear in Finder, but it's clearly there when you list the directory in Terminal.

Update: This issue may be caused by Gatekeeper Path Randomization, AKA App Translocation.


Check whether the app is running from the Downloads folder. If so, try dragging the app to the Applications folder, and this might solve the problem.

Very interesting! Thanks for the heads up on this!

I've also encountered this issue with the same circumstances. The app built fine on my Mac, but when I airdropped it to another Mac running Catalina and Safari 13.1.1, it kept producing SFErrorDomain Code=1 when checking the extension status. The solve was to move the containing app from ~/Downloads to /Applications.


This is an app signed with a Developer ID, but I also saw the problem after notarization.


I often try apps from my Downloads folder, and I'd bet I'm not the only person who does that. Hope this can be fixed...

Safari app extension not detected in showPreferencesForExtension
 
 
Q