【发布时间】:2018-08-22 09:56:19
【问题描述】:
我在 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()
}
【问题讨论】:
标签: macos service info.plist