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

南楼画角 提交于 2019-11-30 07:02:17
mahal tertin

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.

You need to add the com.apple.security.scripting-targets sandboxing entitlement to script other apps from within the sandbox.

To work with Apple Script from your app you have to add the bundle identifiers of the app you want to send or receive events from in the entitlements file.

Here is the syntax:

<key>com.apple.security.temporary-exception.apple-events</key>
<array>
    <string>{bundle identifier of app 1}</string>
    <string>{bundle identifier of app 2}</string>
</array>

You can have one or multiples app bundle identifiers in that array. Now, these apps can receive your apple events commands.

Example:

<key>com.apple.security.temporary-exception.apple-events</key>
<array>
    <string>com.apple.finder</string>
    <string>com.apple.systemevents</string>
    <string>com.microsoft.excel</string>
</array>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!