Can a system preference pane register a login item in Ventura?

I have a system preference pane that contains a background-only app that it wants to set as a login item. I understand that the proper way to set up login items in Ventura is by using the new SMAppService framework. In order to do so, I need an instance of SMAppService. I can't create it using +[SMAppService loginItemServiceWithIdentifier:], because that assumes that the login item is embedded in the calling app, and in this case the calling app is System Preferences. That leaves having the app itself get the mainAppService class property. But when I do that, and then ask the service for its status, the result is SMAppServiceStatusNotFound. That's documented as:

An error occurred and the framework couldn’t find this service.

What kind of error??? When I try this, I see some messages in Console from the tccd process that look like they might be related, but they don't clarify what's wrong.

Must I just give up on using a system preference pane, and make my utility a plain old app containing a helper app?

SMAppService was designed to be called from an app and I very much doubt you’ll make any headway trying to use it from a preferences pane. In the short term, I see two choices here:

  • Continue with your old mechanism for installing login item.

  • Ship a separate app that acts as a container for your login item, which can then use SMAppService.

IMO the long-term solution is to for Apple to deprecate the legacy preferences pane plug-in model in terms of something that’s package as an app extension. That would make everyone’s life easier. If you agree, I encourage you to file an enhancement request along those lines.

Please post your bug number, just for the record.

Share and Enjoy

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

Can a system preference pane register a login item in Ventura?
 
 
Q