我必须指定哪些权利才能使用默认值,在NSTask()中写入com.apple.screencapture [英] What entitlements must I specify to use defaults write com.apple.screencapture in NSTask()
问题描述
我让应用正常运行,然后提交到应用商店,发现了这个叫做沙箱的东西:-p
I got the app working fine then went to submit to the app store and discovered this thing called the sandbox :-p
我一直在阅读文档和开发人员论坛,但是我无法具体弄清楚我需要添加哪些权利才能使此功能正常工作:
I have been reading the documentation and developer forums, but I cant figure out specifically what entitlement I need to add to get this working:
let task = NSTask()
task.launchPath = "/bin/bash"
task.arguments = ["-c",
"defaults write com.apple.screencapture type gif;killall SystemUIServer"]
task.launch()
我曾经认为com.apple.screencapture
和com.apple.security.temporary-exception.shared-preference.read-write
可能是BOOLEAN YES可以解决问题,但不幸的是
I've thought perhaps com.apple.screencapture
and com.apple.security.temporary-exception.shared-preference.read-write
as BOOLEAN YES might do the trick, but unfortunately not
推荐答案
在没有NSTask且没有shell的情况下执行此操作:
Do it without NSTask and without the shell:
对于默认设置,请使用com.apple.security.temporary-exception.shared-preference.read-write
并添加您要修改的域(例如com.apple.screencapture),然后使用CFPreferencesSetValue()
For defaults write use com.apple.security.temporary-exception.shared-preference.read-write
and add the domain you'd like to modify (eg. com.apple.screencapture) and then use CFPreferencesSetValue()
对于killall
,请使用com.apple.security.temporary-exception.apple-events
并运行Applescript/发送AppleEvents以终止特定进程.
For killall
use com.apple.security.temporary-exception.apple-events
and run an Applescript / send AppleEvents to terminate specific processes.
如您所见,这两种权利都是暂时的,您需要充分的理由使它们通过审核.沙箱的目标是使应用程序不干扰其他应用程序.特别是终止SystemUIServer可能会非常麻烦.
As you see, both entitlements are temporary and you need good reasons to get them pass the review. Goal of sandbox is that apps don't interfere with other apps. Especially terminating SystemUIServer can be very intrusive.
这篇关于我必须指定哪些权利才能使用默认值,在NSTask()中写入com.apple.screencapture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!