macos - 如何更改 info.plist 中的 NSServices 并在系统中进行更改?
问题描述
我在 info.plist 中添加服务,例如
<key>NSServices</key>
<array>
<dict>
<key>NSMessage</key>
<string>service</string>
<key>NSPortName</key>
<string>ServiceDemo</string>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Service Demo</string>
</dict>
<key>NSRestricted</key>
<false/>
<key>NSRequiredContext</key>
<dict/>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
</array>
</dict>
</array>
运行应用程序,一切正常。现在,我想更改一些值,但是在我编辑 info.plist -> 运行 -> 在终端中键入命令之后
/System/Library/CoreServices/pbs -dump_pboard
没有改变。我尝试清理 DerivedData -> 重新启动 Xcode -> shift+command+K -> 运行,没有任何改变。重新启动计算机没有帮助。我想知道如何在首次启动时安装 info.plist 中的服务?以及当我运行应用程序时如何进行更改?
顺便说一下,这些代码在 AppDelegate.swift 中
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSApplication.shared.servicesProvider = ServiceProvider()
NSUpdateDynamicServices()
}
有关详细信息,请参阅GitHub 上的演示
解决方案
你试过/System/Library/CoreServices/pbs -update
在 XCode 中构建应用程序后运行吗?
推荐阅读
- flutter - 如何在图像中添加滑动点
- java - 从 MySQL 表生成 java 实体
- vscode-remote - 如何在 dockerfile 中安装 vscode 扩展?
- macros - 宏去 Julia 中的结构定义
- c# - 如何观察由于 C# 中另一个等待任务失败而未等待的任务?
- google-cloud-platform - 如何使用 gcp 附加本地 ssd 创建实例
- r - 在ggplot中标记每组中的极值
- mongodb - 具有聚合框架的嵌套组
- node.js - 在 Node.js 中连接到 SQL Server Express
- database - 从 JanusGraph 中删除数百万级的顶点