Get the OPML UTI by filename extension, to handle the cases where it’s registered as something other than org.opml.opml.

This commit is contained in:
Brent Simmons committed 2025-12-05 09:15:44 -08:00
1 parent 72a8592caa
commit 962177cbef
1 file changed
+20 -4
+20 -4
View File
@@ -415,11 +415,27 @@ private extension SettingsViewController {
}
func importOPMLDocumentPicker() {
var contentTypes: [UTType] = []
let docPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.opml, UTType.xml], asCopy: true)
docPicker.delegate = self
docPicker.modalPresentationStyle = .formSheet
self.present(docPicker, animated: true)
// Create UTType for .opml files by extension, without requiring conformance.
// This ensures files ending in .opml can be selected no matter how OPML is registered.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4858>
if let opmlByExtension = UTType(filenameExtension: "opml") {
contentTypes.append(opmlByExtension)
}
// Also try the registered org.opml.opml UTI if it exists
if let registeredOPML = UTType("org.opml.opml") {
contentTypes.append(registeredOPML)
}
// Include XML as a fallback
contentTypes.append(.xml)
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: contentTypes, asCopy: true)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true)
}
func exportOPML(sourceView: UIView, sourceRect: CGRect) {