如何找到具有相同捆绑标识符的多个应用程序

如何找到具有相同捆绑标识符的多个应用程序

本文介绍了如何找到具有相同捆绑标识符的多个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个好的方法来找到(在文件系统中)具有给定bundle标识符的每个应用程序? NSWorkspace 并且启动服务允许您通过软件包标识符查找应用程序,但只返回一个结果。我怀疑Spotlight( NSMetadataQuery )可能有帮助,但我有点不清楚其API,所以我不知道是否有一个适当的密钥。



有一个命令行 lsregister 工具(在LaunchServices.framework内),可以告诉注册系统上的一切,然后转储一个报告,它知道的一切。依赖于这似乎不太理想,因为它是无证的,并解析其输出可能是一个痛苦。



(背景:我正在构建一个应用程序的游戏改装,提供UI,以便从支持的游戏的简短列表中快速选择,而不是要求用户在打开面板中挖掘整个文件系统。但是,我预计用户很可能会安装一个游戏的多个副本:发布和beta,额外的副本的修改等)

解决方案

2012年提出这个问题涉及OS X Lion 10.7。从OS X Yosemite 10.10的答案是:




Does anyone know of a good way to find (in the filesystem) every app with a given bundle identifier? NSWorkspace and Launch Services let you look for an app by bundle identifier, but only return a single result. I suspect Spotlight (NSMetadataQuery) might help, but I'm a bit unclear on its API, so I'm not sure if there's an appropriate key.

There's the command-line lsregister tool (inside LaunchServices.framework), which can be told to (re)register everything on the system and then dump a report on everything it knows about. Relying on that seems less than ideal, since it's undocumented and parsing its output could be a pain.

(Background: I'm building an app for game modding, and want to provide UI for quickly choosing from a short list of supported games rather than requiring the user to dig through the whole filesystem in an Open panel. However, I expect it's quite likely for a user to have multiple copies of a game installed: release and beta, extra copies for modding, etc.)

解决方案

This question was asked in 2012 concerning OS X Lion 10.7. As of OS X Yosemite 10.10 the answer is:

LSCopyApplicationURLsForBundleIdentifier

这篇关于如何找到具有相同捆绑标识符的多个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 09:55