I'm using a document picker to import data into an app. One of the files to import is a .GPX (it's actually an XML file of GPS data, but that's not relevant). I define a custom file type (as it's not covered by the standard file types covered within UniformTypeIdentifiers)

let documentsPicker = UIDocumentPickerViewController(documentTypes: ["com.sourceapp.gpx"], in: .open)

and register it in info.plist as a Document type, and include this in Exported type identifiers and, seeing as it is not a bespoke file type, in Imported type identifiers. These are all still required as the app target is pre-iOS 14 (for 14+ it's not necessary to add the items to info.plist).

This works fine in the simulator where it's a clean environment without any other apps installed. On a device however it doesn't work, and the file is greyed out and not selectable. I'm reasonably certain this is because a custom file type with the same extension is already registered by another app.

So how do I go about using a file type that has already been registered? There must be a "correct" way to go about this as it must be a common scenario.

My understanding was that this is what the Imported type identifiers was for, but I can't seem to get this to work. This may be because I'm not defining the imported type in exactly the same way as the first app to register it.

If so, how do I see what has already been registered, and reuse it? This would need to be a generic apprach as a scenario where a different app has already regsitered the file type but in a different way is highly likely for a common file type such as .gpx

As background, when using a pre-defined file type such as "public.comma-separated-values-text" for a CSV file all works fine.

UPDATE: I've since seen as the bottom line of documentation that the exported type identifiers overrides imported type identifiers, so have tried deleting the exported one, butit makes no difference.

0

There are 0 answers