Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have created a OS X launch agent that is installed per user. It is listening socket and automatically launched when socket connection arrives. On my .plist I have

    <key>ProgramArguments</key>
    <array>
<string>~/Library/Containers/com.mycompany.myproduct/myproduct.app/Contents/MacOS/myproduct</string>
    </array> 

When connecting to my launch agent socket I get a message in console saying my launch agent is not found. When changing .plist ProgramArguments to

<string>/Users/myusername/Library/Containers/com.mycompany.myproduct/myproduct.app/Contents/MacOS/myproduct</string>

Launch agent is loaded correctly. So it looks like I need to modify .plist for each user during launch agent installation. How can I do this automatically or easily? Is there a standard way for this? Or should I do something totally differently here to achieve what I want?

share|improve this question
    
Why not install for all users and so in /Library/Containers/com.mycompany.myproduct/.... –  Mark Jul 1 '13 at 12:42
    
Mark, my user agent is a helper app for Mac App Store app - should I then install it for all users? Users can download the helper from my website to extend main app functionality beyond sandbox limits. If yes I should probably also move launch agent from ~/Library/LaunchAgents/ to /Library/LaunchAgents/ ? –  superg Jul 1 '13 at 13:04
    
Also, there is no directory /Library/Containers/ on my Mac, should I just create one for my launch agent to work? –  superg Jul 1 '13 at 14:49

1 Answer 1

Use EnableGlobbing:

<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
    <string>~/Library/Containers/com.mycompany.myproduct/myproduct.app/Contents/MacOS/myproduct</string>
</array> 

It works with ProgramArguments but not with Program.

share|improve this answer
    
I thought there is something like this, but never seen it before. Brilliant. –  superg Jul 1 '13 at 12:59
    
Based on documents this is what I need, but after adding EnableGlobbing to my plist I still get the same error. –  superg Jul 1 '13 at 14:26
    
I solved the problem by installing launch agent to /Library/LaunchAgents. –  superg Jul 3 '13 at 6:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.