Updating Safari content blocker from daemon

I'm building a Safari content blocker extension. The app is able to use SFContentBlockerManager.reloadContentBlocker to update the content blocker's JSON rules.

However, I'm also trying to update the rules in the background through a daemon. The daemon app is embedded inside the main app, and is registered by the main app through SMAppService.

The issue I'm running into is I can't get both the GUI app and the daemon to both update the content blocker:

  • If I embed the Safari extension inside the main app and not the daemon, the main app is able to update the extension, but the daemon fails with an "operation couldn’t be completed" error (supposedly because it isn't the owner of the app)
  • Alternatively, if I embed the extension inside the daemon, the main GUI app can no longer update the extension (also failing with "operation couldn't be completed"
  • If I try to embed the extension inside both the main app and the daemon, it works fine when running from Xcode, but App Store Connect verification fails because it won't allow an bundle ID with two periods after the main app ID (e.g. the main app is com.example.App, the daemon is com.example.App.daemon, and the extension is com.example.App.daemon.extension)

I'm wondering if I'm missing something here? Is there a way to get Safari to recognize both the main app and the daemon as "owners" of the extension?

Thanks in advance!

Post not yet marked as solved Up vote post of altxg Down vote post of altxg
352 views

Replies

I’m confused by your goal here. First things first, let me check your terminology. You wrote:

However, I'm also trying to update the rules in the background through a daemon. The daemon app is embedded inside the main app, and is registered by the main app through SMAppService.

How exactly are you registering this “daemon”? Using the daemon(plistName:) method? Or something else?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Sorry, I am indeed mixing up some terminology here. I'm registering a launch agent, not a system-wide daemon, and I'm using SMAppService.agent(plistName:) to do so.

The goal is to have this agent launch on an interval (every day — via a StartInterval key in the agent plist), where it will fetch updated rules for the content blocker.