How to read files on an external drive plugged into the Lightning port

I read that since iOS13 its possible to read an external drive connected via the Lightning port.

Is it possible to read files from myApp? If so how.

Thanks!

Accepted Reply

I'm now fearing that iOS cannot mount a FAT formatted storage device.

iOS can definitely mount FAT volumes over USB. Rather than testing with your app, I recommend that you test with the Files app. If the FAT volume doesn’t show up there, you know that it’s a problem with the mounting process rather than anything related to your code.

If it does turn out to be a problem with the mounting process, I recommend that you retest with a USB thumb drive. If that works and your camera fails, this issue is specific to the camera.

On the USB thumb drive front, you’ll need one of two configurations:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Your link to the adapter was the golden key! Now everything works fine for most of my cameras - I get same results using Files as with my own app. Thank you ever so much (I totally did not know about this adapter!)

    One wrinkle - it seem that one camera does not appear as a FAT storage device, but instead offers a PTP protocol interface that both "Image Capture" and Photos can use on the Mac, and also Photos on iOS.

    But - is there anyway using any iOS device (like one with a USB-C) or any adapter/cable - so my app could also use PTP to retrieve files? [Previous unanswered question in this but its years old: On iPad Pro, is there any way to access USB device by PTP/MPT with USB-C “wired” connection?

Add a Comment

Replies

Is it possible to read files from myApp?

Yes. To do this, use the document picker API for your UI framework to request that the user choose a file. That’ll give you back a URL that you can then read and write like any other security-scoped URL.

For example, for UIKit you’d use the UIDocumentPickerViewController class.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • I finally got some time to play around with this. My ultimate goal is to let users of 360 cameras pull files via a wire, which has to be a lot faster than using HTTP.

    In any case, I have a few 360 cameras with micro-USB connectors. I can plug them into my Mac, and because the camera exposes its storage as a MS-FAT storage device, the Mac can examine the directories and see all the files.

    I have a known good Lightning <-> USB-Micro cable (Insta brand, have used it to wire the Insta camera to my App as an External Accessory). When I plug the camera into the Mac, it flashes a blue LED to indicate a connection. When I plug the same camera into my iPhone, running the test app I wrote, it never appears in the Browser "Locations" list. I tried multiple cameras, restarting my app after the connection, etc. Never changes.

    I'm now fearing that iOS cannot mount a FAT formatted storage device. Is all hope lost?

    CODE: let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.directory, UTType.mpeg4Movie], asCopy: true) // ios14

    documentPicker.delegate = self

    documentPicker.allowsMultipleSelection = false

    documentPicker.modalPresentationStyle = .fullScreen

    present(documentPicker, animated: true, completion: nil)

Add a Comment

I'm now fearing that iOS cannot mount a FAT formatted storage device.

iOS can definitely mount FAT volumes over USB. Rather than testing with your app, I recommend that you test with the Files app. If the FAT volume doesn’t show up there, you know that it’s a problem with the mounting process rather than anything related to your code.

If it does turn out to be a problem with the mounting process, I recommend that you retest with a USB thumb drive. If that works and your camera fails, this issue is specific to the camera.

On the USB thumb drive front, you’ll need one of two configurations:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Your link to the adapter was the golden key! Now everything works fine for most of my cameras - I get same results using Files as with my own app. Thank you ever so much (I totally did not know about this adapter!)

    One wrinkle - it seem that one camera does not appear as a FAT storage device, but instead offers a PTP protocol interface that both "Image Capture" and Photos can use on the Mac, and also Photos on iOS.

    But - is there anyway using any iOS device (like one with a USB-C) or any adapter/cable - so my app could also use PTP to retrieve files? [Previous unanswered question in this but its years old: On iPad Pro, is there any way to access USB device by PTP/MPT with USB-C “wired” connection?

Add a Comment

is there anyway using any iOS device (like one with a USB-C) or any adapter/cable - so my app could also use PTP to retrieve files?

I don’t think so. PTP support is built in to the OS and AFAIK it has no API.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"