首页 > 解决方案 > 使用 Xcode - 安装自定义字体以供 mac 中的所有应用程序使用

问题描述

我正在尝试使用 AppleScript 安装字体。该脚本运行成功,它从脚本编辑器安装了字体,但是当尝试从我的应用程序运行时,它失败并显示以下消息:

NSAppleScriptErrorBriefMessage - 无权将 Apple 事件发送到 Font Book。

我已经尝试了来自此链接的大多数建议解决方案: How to run an AppleScript from a sandboxed application on a Mac (OS X),但它不起作用。

以下是文件 App.entitlements 的内容:

<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
    <string>com.apple.finder</string>
    <string>com.apple.systemevents</string>
    <string>com.apple.FontBook</string>
    <string>com.microsoft.Word</string>
</array>
<key>com.apple.security.scripting-targets</key>
<dict>
    <key>com.apple.FontBook</key>
    <string>com.apple.FontBook</string>
 
  </dict>
 </dict>

并在 Info.plist 中添加以下内容:

<key>NSAppleEventsUsageDescription</key>
<string>Please give Unread Mail access to Mail via Apple Script.</string>

标签: swiftxcodemacosfonts

解决方案


推荐阅读