I needed to import an OPML (Outline Processor Markup Language) file from with-in an iOS app. The OPML format is a XML format used for storing outlines but is also commonly used to share lists of subscriptions between RSS feed readers and podcast players.

The problem is that the OPML extension is not one of the standard UTIs (Universal Type Identifiers) supported by Apple so files with the OMPL extension are greyed out in the file browser.

Disabled OPML file in the document picker

To get files to be recognised I needed to define the OPML UTI in the “Imported Type UTIs” for the project. Within Xcode (I’m using Xcode 10.1 so things may be in different places in other versions) there are two ways of doing this, with through the project settings GUI or be adding the entries to the applications Info.plist.

OPML File Import Settings

Using these settings in the info tab of the project settings creates the following entries in the Info.plist file. The icon came from OPML Icon project.

<array>
  	<dict>
		<key>UTTypeConformsTo</key>
		<array>
			<string>public.xml</string>
		</array>
		<key>UTTypeDescription</key>
		<string>OPML File</string>
		<key>UTTypeIconFiles</key>
		<array>
			<string>opml-icon-128x128</string>
		</array>
		<key>UTTypeIdentifier</key>
		<string>public.opml</string>
		<key>UTTypeTagSpecification</key>
		<dict>
			<key>public.filename-extension</key>
			<array>
				<string>opml</string>
			</array>
		</dict>
	</dict>
</array>

The “Conforms To” field needs to be one of the UTIs Apple already recognises. In this case as the OPML uses XML I used the public.xml UTI. With these settings in the project I changed the document types parameter of my UIDocumentPickerViewController initialiser to include the new public.opml document type and the opml files where then accessable from my app.

let documentPicker = UIDocumentPickerViewController(documentTypes: [public.opml], in: UIDocumentPickerMode.import)

Enabled OPML file in the document picker