【发布时间】:2017-09-23 17:49:10
【问题描述】:
我正在尝试使用它自己的图标创建一个文档包,macOS 将其视为文件,并且您必须选择“显示包内容”才能将其作为文件夹打开。我添加了一个文档类型,当传递与 UTI 匹配的 ofType:"Family Diagram" 时,NSDocument::initWithContentsOfURL 会正确打开它。
但该图标未设置在扩展名为 .fd 的文件夹上,macOS 仍将它们视为文件夹。我将 LSTypeIsPackage 设置为 true。
这是我的 info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>17A362a</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>fd</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>PKDiagram-Document</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-fd</string>
</array>
<key>CFBundleTypeName</key>
<string>Family Diagram</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>FD</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSTypeIsPackage</key>
<true/>
<key>NSDocumentClass</key>
<string>DiagramDocument</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>Family Diagram</string>
<key>CFBundleGetInfoString</key>
<string>Created by Vedanā Media</string>
<key>CFBundleIconFile</key>
<string>PKDiagram-Filled.icns</string>
<key>CFBundleIdentifier</key>
<string>com.vedanamedia.familydiagrammac</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>9A235</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>17A360</string>
<key>DTSDKName</key>
<string>macosx10.13</string>
<key>DTXcode</key>
<string>0900</string>
<key>DTXcodeBuild</key>
<string>9A235</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.healthcare-fitness</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
这里是 Xcode 中 UTI 的截图,注意图标被识别:
【问题讨论】: