Unable to register loginItem via SMAppService - Status Error 78

We were using API "SMLoginItemSetEnabled" earlier to register loginItem with launchd. loginItem(helperApp) registers with launchd and on next reboot launchd service launches helperApp which in-turn launches mainApp.

Our loginItem app is bundled within mainApp LoginItem path: $mainAPP.app/Contents/Library/LoginItems/helper.app

But since it got depreciated in macOS 13 so we are planning to use new API's of "SMAppService" as suggested in this link https://developer.apple.com/documentation/servicemanagement/updating_helper_executables_from_earlier_versions_of_macos.

But on invoking the register() API of SMAppService it returns success but fails to register with launchd service.

On checking the status for our loginItem in terminal via command launchctl list it shows as 78

Also on checking launchd logs we observed errors related to our loginItem

Please suggest if any other changes are need to be done. Thanks in Advance.

Error 78 is EX_CONFIG, indicating that launchd is not happy with the way the job’s property list is set up.

Some questions:

  • Are you using +loginItemServiceWithIdentifier:? Or mainAppService? Or maybe even +agentServiceWithPlistName:?

  • What does the resulting launchd property list file look like?

Share and Enjoy

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

Hi Eskimo

Thanks for your reply.

Are you using +loginItemServiceWithIdentifier:? Or mainAppService? Or maybe even +agentServiceWithPlistName:? +We are using loginItemServiceWithIdentifier.

What does the resulting launchd property list file look like? Not sure how and where to check on the launchd property list file. Could you please share steps to check on the same.

Not sure how and where to check on the launchd property list file.

Hmmm, for a login item we might not actually create one in any easy-to-access place.

Try this:

  1. On a machine running a fresh version of macOS that’s never seen your app before… [I typically use a VM for this sort of thing.]

  2. Install a single copy of your app in the Application directory.

  3. Run it and enable your login item.

Does that work?

Share and Enjoy

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

Hi Eskimo

We followed the steps you had mentioned and verified our app on fresh version of macOS 13 its working as expected.

And below mentioned is screenshot of launchd logs there were no signs of errors or warning this time.

Could you please let us know why it works as expected only on fresh version of macOS but not on already installed macOS. How to check what's going wrong with our app in the already installed version of macOS?

Could you please let us know why it works as expected only on fresh version of macOS but not on already installed macOS.

Many macOS subsystems rely on the Launch Services database to track the location of apps. These can fail mysteriously if the LS database is having problems. This commonly crops up on development machines, where you’re continuously building and rebuilding your app. That’s why, when folks are having mysterious problems with a tech that relies on LS, I always recommend that they retest on a fresh machine.

These problems do crop up on real user’s machines as well, but they’re much less common there.

On your development machine, the #1 tip for resolving these problem is to find and delete any build of your app other than the one you’re actively developing.

Share and Enjoy

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

Thanks for your reply. Sure will give a try.

Unable to register loginItem via SMAppService - Status Error 78
 
 
Q