SwiftUI .fileImporter and custom UTType

Hi,

I want to import GPX files into my iOS App. It works fine in the simulator using:

.fileImporter(isPresented: $showFileImporter, allowedContentTypes: [UTType(filenameExtension: "gpx")!,
UTType(filenameExtension: "GPX")!],
allowsMultipleSelection: true)

But running the app on an actual device (iOS 15 Beta 6), I am not allowed to select any of the GPX files. The strange thing is, that if I am using "jpg" instead of "gpx" I can select "jpg" files just fine. So it seems, that it has to do something with the "GPX" type being 'custom'.

Any idea/hint what I am missing?

Thank you!

  • Michael

It only does not work, if the data is stored on iCloud Drive. If it is copied over locally on the iPad it works. So the real question is: How do I make it work on iCloud Drive as well...

Hello! it works

let gpxType = UTType(exportedAs: "com.topografix.gpx", conformingTo: .xml)

...............

 .fileImporter(isPresented: $openFile,            allowedContentTypes: [.xml, gpxType],            allowsMultipleSelection: true) { (result) in

Sergey

SwiftUI .fileImporter and custom UTType
 
 
Q