为应用程序的文档类型注册图标 [英] Registering an icon for my application's document type
问题描述
我尝试为应用程式的文件类型注册图示。阅读声明新的统一类型标识符并查看 / Developer / Examples / Sketch
我在我的 Info.plist
:
I'm trying to register an icon for my app's document type. After reading Declaring New Uniform Type Identifiers and looking at /Developer/Examples/Sketch
I came up with something like this in my Info.plist
:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycompany.myextension</string>
</array>
<key>NSDocumentClass</key>
<string>NSString</string>
</dict>
</array>
...
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>Blah blah blah</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIconFile</key>
<string>My-file-icon.icns</string>
<key>UTTypeIdentifier</key>
<string>com.mycompany.myextension</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>myextension</string>
</array>
</dict>
</dict>
</array>
现在,一切都很好,dandy,即我的程序打开时,扩展等。但是,文档图标未注册到操作系统,即我看到一个丑陋的空白图标,而不是我美丽的 My-file-icon.icns
。
Now, everything is fine and dandy, i.e. my program is opened when I click on a file with my extension, etc. However, the document icon is not registered with the OS, i.e. I see an ugly blank icon instead of my beautiful My-file-icon.icns
. I suspect that I'm missing something in the plist above, any ideas?
推荐答案
尝试将图标名称放在<$数组中的 UTExportedTypeDeclarations
数组中。
Try putting the icon name in the CFBundleTypeIconFile
key in the CFBundleDocumentTypes
array, not in the UTExportedTypeDeclarations
array.
当然要确保My-file-icon.icns在目标的复制包资源构建阶段,并且被复制到应用程序的
And of course make sure that "My-file-icon.icns" is in your target's Copy Bundle Resources build phase and is being copied into Contents/Resources in your app's bundle.
这篇关于为应用程序的文档类型注册图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!