如何在Mac(OS X)上的沙盒应用程序中运行AppleScript

anu*_*nuj 10 cocoa applescript entitlements mac-app-store appstore-sandbox

我们正在使用Mac OSX 10.9上的Qt 5.2.0.Framework为Mac App Store开发应用程序.

这是一个简单的AppleScript,可以创建Microsoft Excel工作簿并保存到任何位置.

tell application "Microsoft Excel"
    set myworkbook to make new workbook
    set fname to POSIX file "/Private/var/root/Download/ExcelFile" as text
    save workbook as myworkbook filename fname
end tell
Run Code Online (Sandbox Code Playgroud)

上面的脚本保存为Untitled.scpt/Library/ApplicationScript/.

在应用程序内部,我们使用Cocoa框架来执行AppleScript.

此AppleScript在非沙盒应用程序中工作.它在沙盒应用程序中失败.

我的问题是:如何在沙盒应用程序中使用AppleScript?或者有替代方案吗?

请告诉我解决方案,因为我的项目因此而被推迟.

谢谢

在此输入图像描述

在此输入图像描述

mah*_*tin 9

您的代码有两个问题:

  • Excel可能还不支持com.apple.security.scripting-targets,所以你需要com.apple.security.temporary-exception.apple-events(看这里如何找出它是否支持它,以及如何通过添加你想要定位的bundle-identifier数组来处理临时异常.你在那里有这个问题的旧截图.)

  • 脚本目标以及for的权利com.apple.security.temporary-exception.apple-events是一组bundle-identifier.你会在Xcode中看到它像这样:com.apple.security.temporary-exception.apple事件

  • Mac App Store应用程序不得在共享位置安装任何内容/Library/ApplicationScript(请参阅App Store Review Guidelines Section 2.15).您需要将Script存储在Container中并从那里运行它.