2016-06-13 127 views
0

我尝试在Calendar.app中显示一个元素,以便日历被激活并且相应的事件被突出显示。我知道该怎么做,但一旦沙盒是,我只是得到发送AppleEvent失败并显示沙箱

Calendar got an error: A privilege violation occurred.

我的代码简单说就是(甚至没有试图表明一个事件,但只是阅读一个日历):

import Cocoa 

@NSApplicationMain 
class AppDelegate: NSObject, NSApplicationDelegate { 
    func applicationDidFinishLaunching(aNotification: NSNotification) { 
    let source = "tell application \"iCal\"\n set theCalendar to first calendar whose name = \"test\"\nend tell" 
    let scriptObject = NSAppleScript(source: source) 
    var errorDict: NSDictionary? = nil 
    _ = scriptObject!.executeAndReturnError(&errorDict) 
    print (errorDict) 
    } 
} 

而且我应享权利看起来像:

<dict> 
    <key>com.apple.security.app-sandbox</key> 
    <true/> 
    <key>com.apple.security.scripting-targets</key> 
    <dict> 
    <key>com.apple.ical</key> 
    <array> 
     <string>com.apple.ical.read</string> 
    </array> 
    </dict> 
</dict> 

我也尝试过使用脚本桥,但仍失败(以较少的信息,但可能由于同样的原因)。

回答

1

Calendar.app中权利com.apple.security.scripting-targets的失败似乎是一个错误(即使在脚本中使用tell application "Calendar")。

但是全局临时例外的工作原理:

<key>com.apple.security.temporary-exception.apple-events</key> 
<array> 
    <string>com.apple.ical</string> 
</array> 
+0

哇。我做了一个快速测试,但只用我的简化例子,这似乎是窍门。我现在就尝试使用完整版本。 –

+0

非常酷。特别是苹果所谓的“支持”并没有指出我的方向,但让我忍饥挨饿3年多的支持请求。非常感谢你!! –

相关问题