OSX 自定义扩展图标关联

发布于 2024-09-11 10:36:02 字数 2259 浏览 5 评论 0 原文

我试图让我的应用程序使用以下代码显示自定义文件扩展名的图标:

<key>CFBundleDocumentTypes</key>
   <array>
       <dict>
           <key>CFBundleTypeName</key>
           <string>My Custom Extension</string>
           <key>CFBundleTypeRole</key>
           <string>Viewer</string>
           <key>LSItemContentTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
           <key>LSHandlerRank</key>
           <string>Owner</string>
           <key>NSExportableTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
       </dict>
    </array>
   <key>UTExportedTypeDeclarations</key>
   <array>
           <dict>
                   <key>UTTypeIconFile</key>
                   <string>Myicon.icns</string>
                   <key>UTTypeDescription</key>
                   <string>My Custom Extension</string>
                   <key>UTTypeConformsTo</key>
                   <array>
                           <string>public.data</string>
                   </array>
                   <key>UTTypeIdentifier</key>
                   <string>com.myapp.myext</string>
                   <key>UTTypeReferenceURL</key>
                   <string>http://www.myapp.com</string>
                   <key>UTTypeTagSpecification</key>
                   <dict>
                           <key>public.filename-extension</key>
                           <array>
                                   <string>myext</string>
                           </array>
                   </dict>
           </dict>
   </array>

我尝试使用 UTTypeIconFileCFBundleTypeIconFile,并且图标是存在于应用程序包内的 Content/Resources 文件夹下,但在查看具有我的文件扩展名的文件时,我仍然看到一个空白图标,

我不确定这是否重要,但此应用程序是使用 JavaApplicationStub 启动的强>(这是一个java应用程序)

任何帮助将不胜感激:)

I'm trying to get my application to display an icon for a custom file extension using the following code:

<key>CFBundleDocumentTypes</key>
   <array>
       <dict>
           <key>CFBundleTypeName</key>
           <string>My Custom Extension</string>
           <key>CFBundleTypeRole</key>
           <string>Viewer</string>
           <key>LSItemContentTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
           <key>LSHandlerRank</key>
           <string>Owner</string>
           <key>NSExportableTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
       </dict>
    </array>
   <key>UTExportedTypeDeclarations</key>
   <array>
           <dict>
                   <key>UTTypeIconFile</key>
                   <string>Myicon.icns</string>
                   <key>UTTypeDescription</key>
                   <string>My Custom Extension</string>
                   <key>UTTypeConformsTo</key>
                   <array>
                           <string>public.data</string>
                   </array>
                   <key>UTTypeIdentifier</key>
                   <string>com.myapp.myext</string>
                   <key>UTTypeReferenceURL</key>
                   <string>http://www.myapp.com</string>
                   <key>UTTypeTagSpecification</key>
                   <dict>
                           <key>public.filename-extension</key>
                           <array>
                                   <string>myext</string>
                           </array>
                   </dict>
           </dict>
   </array>

I've tried using both UTTypeIconFile AND CFBundleTypeIconFile, and the icon is present under my Content/Resources folder inside the app bundle, but I still see a blank icon when looking at files that have my file extension

I'm not sure if it matters, but this application is launched using the JavaApplicationStub (it's a java app)

Any help would be appreciated :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎言笑 2024-09-18 10:36:02

我仅通过使用JavaApplicationStub了解了一些问题。您是否尝试使用 Apple 的 Jar 捆绑程序?您应该能够注册您的文件类型应用程序支持

I read about some problems by using just the JavaApplicationStub. Did you try to build an .app with Apple's Jar Bundler? You should be able to Registering the File Types Your App Supports.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文