导出的 UTI 未被 macOS 接收
Exported UTI not being picked up by macOS
我正在尝试在我的应用程序中导出 UTI,但 macOS (10.3.2) 没有提取它。我在一个较小的项目中复制了我的问题。这是 info.plist
的相关部分:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>Demo of custom file support</string>
<key>UTTypeIconFile</key>
<string>File-512</string>
<key>UTTypeIdentifier</key>
<string>am.customfiledemo.demotxt</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>demotxt</string>
</array>
<array/>
</dict>
</dict>
</array>
我试过重新启动,甚至重建启动服务数据库,但都没有效果:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain ststem -domain user -v
当我使用
检查文件的 UTI 时
mdls -name kMDItemContentType -name kMDItemContentTypeTree file.demotxt
我得到了动态 (dyn.*
) UTI,而不是 am.customfiledemo.demotxt
kMDItemContentType = "dyn.ah62d4rv4ge80k3prr74hu7a"
kMDItemContentTypeTree = (
"dyn.ah62d4rv4ge80k3prr74hu7a",
"public.data",
"public.item"
)
使UTI符合public.data
或com.apple.package
:
Although a custom UTI can conform to any UTI, public.data
or com.apple.package
must be at the root of the conformance hierarchy for all custom UTIs that are file formats (such as documents); otherwise, the system can’t tell if an item on disk has that UTI.
我正在尝试在我的应用程序中导出 UTI,但 macOS (10.3.2) 没有提取它。我在一个较小的项目中复制了我的问题。这是 info.plist
的相关部分:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>Demo of custom file support</string>
<key>UTTypeIconFile</key>
<string>File-512</string>
<key>UTTypeIdentifier</key>
<string>am.customfiledemo.demotxt</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>demotxt</string>
</array>
<array/>
</dict>
</dict>
</array>
我试过重新启动,甚至重建启动服务数据库,但都没有效果:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain ststem -domain user -v
当我使用
检查文件的 UTI 时mdls -name kMDItemContentType -name kMDItemContentTypeTree file.demotxt
我得到了动态 (dyn.*
) UTI,而不是 am.customfiledemo.demotxt
kMDItemContentType = "dyn.ah62d4rv4ge80k3prr74hu7a"
kMDItemContentTypeTree = (
"dyn.ah62d4rv4ge80k3prr74hu7a",
"public.data",
"public.item"
)
使UTI符合public.data
或com.apple.package
:
Although a custom UTI can conform to any UTI,
public.data
orcom.apple.package
must be at the root of the conformance hierarchy for all custom UTIs that are file formats (such as documents); otherwise, the system can’t tell if an item on disk has that UTI.