9

基本的な問題

(Mac)OS Xシステムにインストールされているすべてのアプリケーション、つまりLaunchServicesに登録されているすべてのアプリケーションバンドルを列挙するソリューションを探しています。

うまくいかなかった単純なアプローチ

(注意:lsregisterの下にあります/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister)。

現在、の出力を使用していますlsregister -dump | grep -E '^.*[ \\t]*path:[ \\t]+(\/.*)$' | grep -Eo '\/.*'が、いくつかの問題があります。

  • .app改行(UNIXで有効)を含むバンドル\nは正しく処理されません(この問題は、適切なパーサーを作成することで修正できます)
  • lsregister奇妙なファイル名を正しく処理しません(たとえば、RTLマークを含む)。lsregister名前にRTLマークが含まれているファイルを無視しているようです。必要に応じて、次のコマンドを実行して、名前にRTLが含まれるファイルを作成できます。

    python -c 'import shutil; shutil.copytree(u"/Applications/TextEdit.app", u"/Applications/ThisIsAWeird\u202EApp.app")'
    

    これを行った後、それを明らかにしlsregister -dump | grep ThisIsAWeirdませ。ただし、テキストファイルを右クリックして[プログラムから開く]に移動すると、LaunchServicesとFinderがそのファイルを引き続きサポートします。 自分を見て

LaunchServicesは任意のフォルダー内のアプリケーションバンドルを認識しており、これらのアプリも必要なため、他のディレクトリ内のすべてのファイルを単純に列挙する/Applicationsことはできません。

私が働かなかった他のアプローチ

どうやら、_LSFindApplications私がする必要があることを正確に実行するというプライベートAPI関数がありますが、それを機能させることができず、インターネット上に非公式のドキュメントが見つかりませんでした。(それが存在することの証明nm /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/LaunchServices | grep __LSFindApplications$:)

更新:system_profilerメソッドも機能していないようです

今まで私は@Anoopによって提案された方法が機能しますが、今日はまだより多くのバイナリsystem_profilerを取得することがわかりました。lsregister一部またはすべてのマシンで欠落しているものもありsystem_profilerますが、OS Xの別のインストールで外部ボリュームをマウントした場合にのみ欠落しているようです。私のマシンの1つでの出力に欠落しているsystem_profiler(ただし存在している)もののリストを次に示します。lsregister

/Applications/Automator.app/Contents/Resources/Application Stub.app
/Applications/Google Chrome.app/Contents/Versions/30.0.1599.69/Google Chrome Framework.framework/Resources/app_mode_loader.app
/Applications/Google Chrome.app/Contents/Versions/30.0.1599.69/Google Chrome Framework.framework/Resources/crash_report_sender.app
/Applications/Google Chrome.app/Contents/Versions/30.0.1599.69/Google Chrome Helper EH.app
/Applications/Google Chrome.app/Contents/Versions/30.0.1599.69/Google Chrome Helper NP.app
/Applications/Google Chrome.app/Contents/Versions/30.0.1599.69/Google Chrome Helper.app
/System/Library/CoreServices/AddPrinter.app
/System/Library/CoreServices/AirPlayUIAgent.app
/System/Library/CoreServices/AppleFileServer.app
/System/Library/CoreServices/AppleGraphicsWarning.app
/System/Library/CoreServices/AppleScript Runner.app
/System/Library/CoreServices/AppleScript Utility.app
/System/Library/CoreServices/CalendarFileHandler.app
/System/Library/CoreServices/Certificate Assistant.app
/System/Library/CoreServices/CoreLocationAgent.app
/System/Library/CoreServices/CoreServicesUIAgent.app
/System/Library/CoreServices/CoreTypes.bundle
/System/Library/CoreServices/Database Events.app
/System/Library/CoreServices/DiskImageMounter.app
/System/Library/CoreServices/Expansion Slot Utility.app
/System/Library/CoreServices/File Sync.app
/System/Library/CoreServices/FileSyncAgent.app
/System/Library/CoreServices/Folder Actions Dispatcher.app
/System/Library/CoreServices/Folder Actions Setup.app
/System/Library/CoreServices/HelpViewer.app
/System/Library/CoreServices/Image Events.app
/System/Library/CoreServices/Install in Progress.app
/System/Library/CoreServices/Jar Launcher.app
/System/Library/CoreServices/Java Web Start.app
/System/Library/CoreServices/KeyboardSetupAssistant.app
/System/Library/CoreServices/Language Chooser.app
/System/Library/CoreServices/LocationMenu.app
/System/Library/CoreServices/MRTAgent.app
/System/Library/CoreServices/Memory Slot Utility.app
/System/Library/CoreServices/NetAuthAgent.app
/System/Library/CoreServices/Network Diagnostics.app
/System/Library/CoreServices/Network Setup Assistant.app
/System/Library/CoreServices/ODSAgent.app
/System/Library/CoreServices/Pass Viewer.app
/System/Library/CoreServices/Printer Setup Utility.app
/System/Library/CoreServices/RegisterPluginIMApp.app
/System/Library/CoreServices/Screen Sharing.app
/System/Library/CoreServices/SecurityAgent.app
/System/Library/CoreServices/SecurityFixer.app
/System/Library/CoreServices/SocialPushAgent.app
/System/Library/CoreServices/System Events.app
/System/Library/CoreServices/System Image Utility.app
/System/Library/CoreServices/SystemUIServer.app
/System/Library/CoreServices/Ticket Viewer.app
/System/Library/CoreServices/UniversalAccessControl.app
/System/Library/CoreServices/UnmountAssistantAgent.app
/System/Library/CoreServices/UserNotificationCenter.app
/System/Library/CoreServices/VoiceOver.app
/System/Library/CoreServices/ZoomWindow.app
/System/Library/CoreServices/backupd.bundle/Contents/Resources/TMLaunchAgent.app
/System/Library/CoreServices/loginwindow.app
/System/Library/CoreServices/rcd.app
/System/Library/Frameworks/PubSub.framework/Versions/A/Resources/PubSubAgent.app
/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuickLookUI.framework/Versions/A/Resources/QuickLookUIHelper.app
/System/Library/Frameworks/QuickLook.framework/Versions/A/Resources/quicklookd.app
/System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/Resources/DiskImages UI Agent.app
/System/Library/Services/AppleSpell.service
/System/Library/Services/ChineseTextConverterService.app
/System/Library/Services/ImageCaptureService.app
/System/Library/Services/OpenSpell.service
/System/Library/Services/SpeechService.service
/System/Library/SocialServices/Facebook.socialplugin
/System/Library/SocialServices/Twitter.socialplugin
/System/Library/SocialServices/Weibo.socialplugin
4

3 に答える 3

7

まず、あなたの要求は完全に正しくありません:

(Mac)OS Xシステムにインストールされているすべてのアプリケーション、つまりLaunchServicesに登録されているすべてのアプリケーションバンドルを列挙するソリューションを探しています。

それらは同じものではありません。LaunchServicesに登録されているアプリケーションバンドルは、の出力ですlsregister -dump。これは、「インストールされているすべてのアプリケーション」と同じではありません。「インストールされているすべてのアプリケーション」に対する正確なクエリはありません。OSXにはそのような概念すらありません。

の出力はsystem_profiler、Spotlightが認識しているものと同等です。これは、インストールされているアプリケーションの完全なリストではなく、場合によっては正しくない可能性があります。たとえば、Spotlightが無効になっているか、最初のスキャンが完了していない可能性があります。(Spotlightが最初のスキャンを終了したかどうかを確認するためのサポートされている方法はありません。レーダー15177626。)

pkgutil --pkgs追加の「インストール済みのもの」を提供するものもあります。どちらも完全ではなく、インストールされていないものがリストされる場合があります。

mdfindまた、ディスク全体を調べて、それ自体をアプリケーションと呼ぶものを確認するために使用することもできます。これはかなり効果的ですが、遅いです。

locate .app | grep '\.app$'また、ロケートデータベースが最新であり、アプリバンドルのみが必要な場合は、これを使用すると非常に効果的です。

私はWWDCでこれについてAppleに尋ねました。簡単でサポートされている答えはありません。レーダーを開きます。15177489を複製するように依頼できます。

于 2013-10-08T18:08:51.647 に答える
1

ここで行われているように、Cocoaアプリケーション/コードを使用して検索するのはどうですか。

また、使用しsystem_profiler -xml SPApplicationsDataTypeて結果のXMLデータを解析し、関心のあるアプリケーションだけを取得できる場合もあります。

于 2013-03-02T02:30:05.843 に答える
1

ターミナルで:

system_profiler SPApplicationsDataType > list_of_all_apps.txt

...system_profilerクエリの出力をそのテキストファイルに書き込みます。

于 2015-04-01T15:24:30.060 に答える