【问题标题】:How to change NSServices which in info.plist and make changes happen in system?如何更改 info.plist 中的 NSServices 并在系统中进行更改?
【发布时间】: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()
}

详见demo on GitHub

【问题讨论】:

    标签: macos service info.plist


    【解决方案1】:

    在 XCode 中构建应用后,您是否尝试过运行 /System/Library/CoreServices/pbs -update

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-07
      • 2020-02-04
      • 2012-09-02
      • 2018-03-20
      • 2013-12-15
      • 2016-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多