【问题标题】:Setting document file icon in Xcode not working?在 Xcode 中设置文档文件图标不起作用?
【发布时间】:2016-04-18 01:05:59
【问题描述】:

我正在尝试将我的应用使用的文件类型(扩展名.sbd)与我的应用相关联,并让保存的文件显示自定义文档图标。我在 Xcode 中设置了 Document Types 部分,如下所示:

这是我的 Info.plist 文档类型部分:

我在这里查看了其他类似的问题,但他们要么提到 CFBundleTypeIconFile,这似乎已被弃用,要么他们无法解决问题。有什么我没有做或做错的事情吗?

【问题讨论】:

  • 您的.icns 文件存储在您的应用程序包中的什么位置?如果还没有,它应该在Resources

标签: xcode macos icons document


【解决方案1】:

尝试将CFBundleTypeRole 设置为Viewer。您的 Info.plist 必须如下所示:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>sbd</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>SBDocumentIcon</string>
        <key>CFBundleTypeName</key>
        <string>icns</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
    </dict>
</array> 

清理并重建您的项目。如果图标没有更新,请尝试重新启动计算机。

【讨论】:

  • 其实它确实有效,只是花了一点时间才生效。也许它需要重建数据库或其他东西?
  • 是的,mac 图标缓存必须刷新,有时需要一点时间。如果重新启动不起作用,可以通过触摸gist.github.com/fabiofl/5873100从命令行重新启动它
猜你喜欢
  • 2019-09-29
  • 2017-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多