Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

cocoa - How to run an AppleScript from a sandboxed application on a Mac (OS X)

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

enter image description here

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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: com.apple.security.temporary-exception.apple-events

  • 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...