添加macOS文档类型图标

问题描述 投票:0回答:1

我正在制作基于文档的macOS应用。我正在尝试添加文档图标。几年前,我已经使用Objective-C做到了这一点,但是在将它用于我的Swift应用程序时遇到了问题。这是我在“信息”部分下得到的内容:

enter image description here

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

enter image description here

[提交给苹果公司时,我收到警告说:

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

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

谢谢您的帮助。我对这种事情还很陌生,所以请和我一起裸露。

xcode macos info.plist
1个回答
0
投票

尝试将类型更改为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>
© www.soinside.com 2019 - 2024. All rights reserved.