SMLoginItemSetEnabled on child app bundle

, Hello,


I have an child app bundle, and am trying to provide a LoginItems helper for it.

However, I find, whether I place it at


/Applications/My.app/Contents/MacOS/My2.app/Contents/Library/LoginItems/My3.app/...

or

/Applications/My.app/Contents/Library/LoginItems/My3.app/...


When My2.app calls SMLoginItemSetEnabled, 'log stream' shows "Could not enable login item: My2: 3: No such process"

Now, open -b My2 works. Where do I need to put My3 for SMLoginItemSetEnabled to work?


Thanks!


James

Replies

If you temporarily pull

My2.app
out of
My.app
, so it’s just a normal standalone app with a XPC login item, does it work then?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

No, oddly enough I still get 3: No such process. What does this mean, exactly?

I have tried adding LSRegisterURL directly before, and it succeeds.

No, oddly enough I still get 3: No such process. What does this mean, exactly?

Error 3 is almost certainly

ESRCH
, which sounds very much like some OS subsystem is reusing a POSIX-style error code for something that’s not really a POSIX error.

I have tried adding

LSRegisterURL
directly before, and it succeeds.

As this is the first time you mentioned

LSRegisterURL
, I’m not sure how to parse that sentence. My best guess is that:
  1. If you take

    My2.app
    out of
    My.app
  2. You still see the error 3 when

    My2.app
    tries to call
    SMLoginItemSetEnabled
  3. But if you call

    LSRegisterURL
    before
    My2.app
    tries to call
    SMLoginItemSetEnabled
  4. Things work

Is that correct?

Are you testing this on your development machine? If so, I suggest you run these tests on a fresh machine each time. Anything related to Launch Services (and the effect of

LSRegisterURL
indicates that this is related to Launch Services) is suspect on development machines. For some background on this, and specific advice on how to test, read this post.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"