OSX Custom extension icon Association

跟風遠走 提交于 2019-12-22 08:35:45

问题


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 :)


回答1:


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.



来源:https://stackoverflow.com/questions/3327526/osx-custom-extension-icon-association

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!