I know how to create a launch agent with a normal application say "myLaunchd" and setting "Application is agent" to "YES" and then copying the "myLaunchd.app" to the main app's Contens/Library/LoginItems
.
But I need agents, which will be created by some scripts and the main-app's bundle-identifier will be provided through command line arguments.
I tried with a console app, tried using it as launch agent, but it doesn't work expected. I noticed that a normal app keeps running until it is closed (if "Application is agent" is set to "NO"). So to achieve similar effect I forced the console app to run-infinitely using while(1)
, but no luck.
Any suggestion will be appreciated.