我写了一个 plist 文件。目的是保持程序正常运行。我发现的问题如下。如果我关闭应用程序并从 /Applications 文件夹启动它,我创建的 helper.plist 将不再有效。现在我知道我可以运行一个卸载和加载launchtctl 的脚本。但这将使用助手的 bundleId 第二次启动我的程序。
如果我手动关闭应用程序,是否有任何方法可以将程序重新附加到帮助程序,或者这是不可能的?或者我是否必须编写一个仅运行脚本并在其源中包含真实程序的包装应用程序?是否有更聪明的解决方案可以轻松完成?我附上了下面的plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com
/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.test.helper</string>
<key>Program</key>
<string>/Applications/test.app/Contents/MacOS/test</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
</dict>
</plist>