UTImportedTypeDeclarations异常及OPML导入导出功能问题求助
Hey there, let's break down and fix your OPML import/export issues step by step:
Issue 1: OPML files turn gray/unusable after installing other OPML-supporting apps
This is almost always a UTI (Uniform Type Identifier) conflict—when multiple apps claim ownership of the same file type, iOS might prioritize another app's declaration over yours. Here's how to resolve it:
- First, make sure your
UTExportedTypeDeclarationsuses the standard OPML UTI:org.opml.opml. Avoid generic identifiers likepublic.opmlsince other apps might be using those too. - In your
CFBundleDocumentTypesconfiguration, set theLSHandlerRanktoOwner. This tells iOS your app is the primary handler for OPML files, reducing the chance of other apps overriding it. - Double-check your UTI declaration's conformance—OPML is an XML-based format, so your
UTTypeConformsToarray should includepublic.xmlandpublic.textto align with system categories. - Finally, uninstall and reinstall your app, then restart your device. iOS caches UTI associations, so a fresh install often clears conflicting entries.
Issue 2: OPML file icons not showing despite adding 22x29 and 44x58 resources
Icon display issues usually stem from missing configuration or cached assets. Try these fixes:
- Add icon references to both UTI and document type declarations:
In yourUTExportedTypeDeclarationsdictionary, add theUTTypeIconFileskey pointing to your icon files (omit the file extension, e.g.,OPMLIcon22x29instead ofOPMLIcon22x29.png).
Also, include the same icon filenames in theCFBundleTypeIconFilesarray underCFBundleDocumentTypes—iOS sometimes pulls icons from this section instead of the UTI declaration. - Verify icon assets:
Ensure your icons are added to your project's target (checkBuild Phases > Copy Bundle Resourcesto confirm they're included). For full compatibility, add a 3x version (66x87 pixels) alongside your 1x and 2x icons. - Clear icon cache:
iOS caches file icons aggressively. Restart your device after updating icon assets or configuration—this is often the missing step to make new icons appear.
Example corrected Info.plist snippets
For your UTI declaration:
<key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.xml</string> <string>public.text</string> </array> <key>UTTypeIdentifier</key> <string>org.opml.opml</string> <key>UTTypeDescription</key> <string>OPML Outline File</string> <key>UTTypeIconFiles</key> <array> <string>OPMLIcon22x29</string> <string>OPMLIcon44x58</string> <string>OPMLIcon66x87</string> <!-- Optional but recommended --> </array> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>opml</string> </array> <key>public.mime-type</key> <string>text/x-opml</string> </dict> </dict> </array>
For your document type association:
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>OPML Outline File</string> <key>CFBundleTypeIconFiles</key> <array> <string>OPMLIcon22x29</string> <string>OPMLIcon44x58</string> <string>OPMLIcon66x87</string> </array> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>org.opml.opml</string> </array> </dict> </array>
Give these steps a try—they should resolve both your grayed-out files and missing icon issues!
内容的提问来源于stack exchange,提问作者Anton Breza
相关产品推荐
相关产品推荐

