如何使用 LaunchDaemons (launchd) 启动 Program.app?

2024-02-23

我放置了以下内容com.apple.test.plist文件夹中的文件:

/系统/库/LaunchDaemons

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.apple.Spotlight</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

但由于某种原因,当我使用用户 todd 登录时,ApplicationTest.app 无法启动。

有任何想法吗?


The key ProgramArguments需要一个可执行文件,但您提供了一个应用程序包,这是一个美化的目录。为了启动应用程序,您必须将 launchd 指向捆绑包内的可执行文件:

<key>ProgramArguments</key>
<array>
<string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app/Contents/MacOS/ApplicationTest</string>
</array>

或者使用open(1)运行应用程序的命令:

<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-W</string>
<string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
</array>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 LaunchDaemons (launchd) 启动 Program.app? 的相关文章

随机推荐