Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 即使我添加了请求更改共享首选项的权限,cocoa沙箱也不总是有效的_Macos_Cocoa_Sandbox - Fatal编程技术网

Macos 即使我添加了请求更改共享首选项的权限,cocoa沙箱也不总是有效的

Macos 即使我添加了请求更改共享首选项的权限,cocoa沙箱也不总是有效的,macos,cocoa,sandbox,Macos,Cocoa,Sandbox,我开发了一个沙盒应用程序。其功能之一是对/Users/username/Library/Preferences com.apple.finder.plist进行一些更改。因此,为了做到这一点,我已将以下内容添加到我的权限.plist中: <key>com.apple.security.temporary-exception.shared-preference.read-write</key> <array> <string>com.appl

我开发了一个沙盒应用程序。其功能之一是对/Users/username/Library/Preferences com.apple.finder.plist进行一些更改。因此,为了做到这一点,我已将以下内容添加到我的权限.plist中:

<key>com.apple.security.temporary-exception.shared-preference.read-write</key>
<array>
    <string>com.apple.finder</string>
</array>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
    <string>com.apple.finder</string>
    <string>com.apple.systemevents</string>
</array>
(来自)

然而,changing finder.plist似乎并不总是有效。(没有错误)但是如果我关闭沙箱,它会工作


所以我的结论是,沙箱破坏了我的代码,但我真的不知道如何解决这个问题,因为我已经添加了权限?

可能您希望启用沙箱使应用商店符合条件。 我认为你将很难(不可能)获得你的应用程序的临时豁免批准,特别是在系统事件和finder方面

如果您被授予这些临时豁免,您几乎可以做任何不需要root访问的事情,例如删除文件等。这会破坏沙箱的目的

从你的应用重新启动Finder是绝对不允许的。我建议你找到另一种方法来做你需要做的事情

tell application "Finder" to quit
set inTime to current date
    repeat
tell application "System Events"
    if "Finder" is not in (get name of processes) then exit repeat
end tell
if (current date) - inTime is greater than 10 then exit repeat
    delay 0.2
end repeat

tell application "Finder" to activate