Enabling start at login with App Sandbox enabled

2020-02-08 18:23发布

问题:

I have an application that must be sandboxed.

It's not a difficult task, but I see that I cannot enable automatic start at login with LSSharedFileList editing the Session Login Items list.

Is there another way to enable start at login with App Sandbox enabled?

回答1:

An updated project/tutorial is available here, with addendums for some misleading Console messages you'll see under 10.8.2:

http://blog.timschroeder.net/2012/07/03/the-launch-at-login-sandbox-project/

I'm not the author, but the tutorial was very helpful in getting a start-at-login app configured under 10.8.2 w/ Sandboxing enabled.



回答2:

Apple says:

Creating a Login Item for Your App To create a login item for your sandboxed app, use the SMLoginItemSetEnabled function (declared in ServiceManagement/SMLoginItem.h) as described in “Adding Login Items Using the Service Management Framework” in Daemons and Services Programming Guide.

(With App Sandbox, you cannot create a login item using functions in the LSSharedFileList.h header file. For example, you cannot use the function LSSharedFileListInsertItemURL. Nor can you manipulate the state of launch services, such as by using the function LSRegisterURL.)