【问题标题】:Adding macOS Document Type Icon添加 macOS 文档类型图标
【发布时间】:2019-11-14 23:09:44
【问题描述】:

我正在制作基于文档的 macOS 应用程序。我想要做的是添加文档图标。几年前我已经使用 Objective-C 完成了这项工作,但是我在让它在我的 Swift 应用程序上工作时遇到了问题。这是我在信息部分得到的:

我的图标名为 JotSpot Doc.png,与所有 Swift 和 Storyboard 文件(不在资产文件夹中)一起放置在项目的根目录中。 这是我的 info.plist 的样子:

向 Apple 提交时,我收到一条警告,上面写着

CFBundleDocumentTypes 字典数组在 'com.website.app' Info.plist 应该包含一个 CFBundleTypeName 'png' 条目的 LSHandlerRank 值。

使用该应用程序保存文档时,它是完全空白的,根本没有图标(甚至没有空白的白色图标)。您实际上必须单击文档名称才能打开文件。

【问题讨论】:

    标签: xcode macos info.plist


    【解决方案1】:

    尝试将类型更改为 image/png。然后添加处理程序等级。

    这是我部分的代码(用于打开 GPX 文件)。

    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>Open Fit File</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.data</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>Open Gpx File</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.apple.dt.document.gpx</string>
            </array>
        </dict>
    </array>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-11
      • 1970-01-01
      • 2021-12-19
      相关资源
      最近更新 更多