【问题标题】:How can I make custom icons appear for document types associated with my macOS app in the Finder?如何在 Finder 中为与我的 macOS 应用程序关联的文档类型显示自定义图标?
【发布时间】:2023-01-25 20:11:48
【问题描述】:

我已成功创建 UTI,并且 Finder 能够识别文件属于我的应用程序并且它们是特定类型(例如 ITC 数据文件)。但是,我无法让操作系统使用我在 Xcode 的属性列表文件中指定的自定义图标。

这是我的 plist 文件的相关部分:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>itc</string>
                <string>vpitc</string>
                <string>ITC</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>DataFileBackground</string>
            <key>CFBundleTypeIconSystemGenerated</key>
            <integer>0</integer>
            <key>CFBundleTypeName</key>
            <string>ITC Data File</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.itcdatafile</string>
            </array>
            <key>NSDocumentClass</key>
            <string></string>
        </dict>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>ftitc</string>
                <string>FTITC</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>ProjectFileIcon</string>
            <key>CFBundleTypeIconSystemGenerated</key>
            <integer>0</integer>
            <key>CFBundleTypeName</key>
            <string>FT-ITC Project File</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.ftitcproject</string>
            </array>
            <key>NSDocumentClass</key>
            <string></string>
        </dict>
    </array>

我以前设法让 Finder 显示自定义测试图标,但我不确定我是怎么做到的,也无法重现它。这些图标在“资产”中定义为“macOS 通用图标”:

如何获得关联文件的自定义图标?更改(如果成功)是否需要时间来更新操作系统?

谢谢。

【问题讨论】:

    标签: xcode macos uti


    【解决方案1】:

    问题可能与系统缓存图标有关。右键单击文件并单击“查看信息”导致系统更新图标。

    当我更新图标 .png 文件时,我还需要这样做以使系统使用新图像作为图标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-09
      • 2015-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      相关资源
      最近更新 更多