【问题标题】:List of URL Scheme Mappings for Apple (Mac and/or iPhone)Apple(Mac 和/或 iPhone)的 URL 方案映射列表
【发布时间】:2015-06-19 07:02:33
【问题描述】:

我正在尝试查找有关与某个应用关联的自定义 URL 映射方案的更多信息。我检查了一些 SO 讨论,但无法得出结论。我有几个关于 URL 方案映射的问题,

  1. 有没有办法(例如某个命令或存储此信息的文件)在给定的 Apple iPhone 或 Mac 上获取 URL 方案及其映射到的应用程序的列表? (我猜答案是否定的 - 基于https://stackoverflow.com/a/10951866/1165727 但我想确认一下,因为这个答案已经很老了)。

  2. 在应用程序上运行“字符串”命令是找出与应用程序关联的 URL 方案的唯一方法吗? (这是基于此答案的 cmets - https://stackoverflow.com/a/5707825/1165727)。

  3. 有没有比 http://wiki.akosma.com/IPhone_URL_Schemes 更完整的 URL Schemes 列表

【问题讨论】:

  • 1) No. 2) 查看应用的 Info.plist 文件。 3) 没有明确的清单。
  • @rmaddy - 您提到的关于查看应用程序的 plist 而不是针对应用程序运行字符串的观点很有帮助。谢谢!
  • 截至 2019 年 12 月 16 日,选项 3 中的链接已损坏。

标签: ios macos url-scheme


【解决方案1】:

根据 Ken Thomases 的回答,这是一个使用 Perl 解析 LaunchServices 数据库中的数据的单行脚本。

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | LC_ALL=C tr '\n' '\a' | perl -pe 's/(-{20}\aBundleClass)/\n\1/g' | perl -e 'sub trim {my $s = shift; $s =~ s/\a//g; $s =~ s/\"//g; $s =~ s/\{//g; $s =~ s/\}//g; $s =~ s/^\s+|\s+$//g; return $s}; sub trimCommas {my $s = shift; $s =~ s/,//g; return $s}; while ($line = <STDIN>) {if (index($line, "CFBundleURLTypes = ") != -1) {$urlTypesData = $line; $urlTypesData =~ s/^.*CFBundleURLTypes = .*?\((.*?)[^es] =.*$/\1/g; $urlTypesData =~ s/(^.*)\).*?$/\1/g; @urlTypes = split("}", $urlTypesData); if (trim($urlTypesData) ne "" && int(@urlTypes) > 1) {$name1 = $path = (split("CFBundleExecutable", $line))[0]; $name1 =~ s/.*name:(.*?)\a.*$/\1/g; $name2 = $line; $name2 =~ s/^.*CFBundleExecutable = (.*?)\;.*$/\1/g; $appName = ((index($name1, "(null)") == -1) ? trim($name1) : trim($name2)); $path =~ s/.*path:(.*?)\a.*$/\1/g; print $appName . "\f   " . "\033[38;5;173m(path: " . trim($path) . ")\033(B\033[m"; for ($i=0; $i<int(@urlTypes)-1; $i++) {$curUrlName = @urlTypes[$i]; if (index(@urlTypes[$i], "CFBundleURLName") != -1) {$curUrlName =~ s/^.*CFBundleURLName =(.*?);.*$/\1/} else {$curUrlName = "\e[3m[Blank]\e[0m"}; $schemesRaw = @urlTypes[$i]; $schemesRaw =~ s/^.*CFBundleURLSchemes =.*?\((.*?)\).*$/\1/g; @schemes = split(",", $schemesRaw); if (trimCommas(trim(@urlTypes[$i])) ne "") {print "\f\t" . trimCommas(trim($curUrlName)); for ($b=0; $b<int(@schemes); $b++) {print "\f\t\t" . trim(@schemes[$b])}}; print "\f"}}; print "\n"}}' | sort -uf | perl -pe 's/(\n)/\1\1\1/g; s/\f/\n/g'

这是输出的几行:

【讨论】:

    【解决方案2】:

    在 OS X 上,您可以使用:

    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump
    

    这显示了 Launch Services 数据库的转储,其中包括 URL 方案及其到应用程序的映射。

    【讨论】:

    • 谢谢,这很有帮助。
    • 这并没有涵盖所有内容。这个post 的答案提供了另外两种选择来显示更多结果。例如,该命令并未显示您可以使用 `dict:\` 字典应用程序
    猜你喜欢
    • 1970-01-01
    • 2011-09-27
    • 2016-05-24
    • 2015-09-20
    • 2012-01-05
    • 1970-01-01
    • 2021-11-12
    • 2012-10-13
    • 1970-01-01
    相关资源
    最近更新 更多