问题描述
我们正在 MacOSX 10.9 上使用 Qt 5.2.0.Framework 为 Mac App Store 开发应用程序.
这是一个简单的 AppleScript,用于创建 Microsoft Excel 工作簿并保存到任何位置.
告诉应用程序Microsoft Excel"设置 myworkbook 以制作新的工作簿将 fname 设置为 POSIX 文件/Private/var/root/Download/ExcelFile"作为文本将工作簿另存为 myworkbook 文件名 fname结束告诉
以上脚本保存为/Library/ApplicationScript/
中的Untitled.scpt
.
在应用程序内部,我们使用 Cocoa 框架来执行 AppleScript.
此 AppleScript 在非沙盒应用程序中工作.它在沙盒应用程序中失败.
我的问题是:您如何在沙盒应用程序中使用 AppleScript?或者有其他替代方法吗?
请告诉我解决方案,因为我的项目因此而延迟.
谢谢
您的代码有两个问题:
Excel 可能还不支持
com.apple.security.scripting-targets
,所以你需要com.apple.security.temporary-exception.apple-events
(见 第 2.15 节).您需要将脚本存储在您的容器中并从那里运行它.
We are developing an application for the Mac App Store using Qt 5.2.0.Framework on MacOSX 10.9.
Here is a simple AppleScript that creates a Microsoft Excel workbook and saves to any location.
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
The above script is saved as Untitled.scpt
in /Library/ApplicationScript/
.
Inside the application, we use the Cocoa framework to execute the AppleScript.
This AppleScript works in a non-sandboxed application. It fails in a sandboxed application.
My question is: How do you use an AppleScript in a sandboxed application? Or is there an alternative to this?
Kindly tell me the solution, because my project is being delayed by this.
Thanks
There two issues with your code:
Excel probably doesn't yet support
com.apple.security.scripting-targets
, so you would needcom.apple.security.temporary-exception.apple-events
(see here how to find out if it supports it and here how to work with the temporary exception by adding an array of bundle-identifiers you want to target. You had that in the old screenshot of this question.)The entitlement of scripting-targets as well as for
com.apple.security.temporary-exception.apple-events
is an array of bundle-identifiers. You would see it in Xcode like this:A Mac App Store app must not install anything in shared locations like
/Library/ApplicationScript
(see App Store Review Guidelines Section 2.15). You need to store the Script inside your Container and run it from there.
这篇关于如何从 Mac (OS X) 上的沙盒应用程序运行 AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!