如何从Mac上的沙箱应用程序(OS X)运行AppleScript [英] How to run an AppleScript from a sandboxed application on a Mac (OS X)

查看:823
本文介绍了如何从Mac上的沙箱应用程序(OS X)运行AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Qt 5.2.0.Framework在MacOSX 10.9上开发一个Mac App Store应用程序。



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

 告诉应用程序Microsoft Excel
将myworkbook设置为make new workbook
设置fname到POSIX文件/ Private / var / root / Download / ExcelFile作为文本
将工作簿保存为myworkbook文件名fname
end tell

上述脚本另存为 Untitled.scpt / Library / ApplicationScript / 。



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



此AppleScript在非沙盒应用程序中工作。



我的问题是:如何在沙盒应用程序中使用AppleScript?



请告诉我解决方案,因为我的项目被延迟。



感谢



/ p>

>

解决方案

您的代码有两个问题:




  • Excel可能还不支持 com.apple.security.scripting-targets ,因此您需要 com.apple.security.temporary-exception .apple-events (请参阅第2.15节)。您需要将Script存储在Container中并从那里运行。



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 need com.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆