Reputation: 41
for my iOS app i want my users to store files in the apps document folder. But it isn't visible on install. I've set both UIFileSharingEnabled
and LSSupportsOpeningDocumentsInPlace
to true
but the folder isn't visible.
I've followed these exact steps described here.
this is how it should be
Upvotes: 4
Views: 2594
Reputation: 91681
I tried following this tutorial, writing a document to the documents directory (see code below), ensuring that both UIFileSharingEnabled
and LSSupportsOpeningDocumentsInPlace
were enabled, but still I was not seeing my App's folder in the File Browser.
It worked in the simulator, but not on a device.
Turns out the fix was to restart the device.
This was running 13.3.1.
Update: Other times even after a restart it would require hitting the back "Locations" button, and then "On My iPad" to refresh the list.
func createFileInDocumentsDirectory() {
let file = "test.txt"
let text = "Hello world"
let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let fileURL = dir.appendingPathComponent(file)
try! text.write(to: fileURL, atomically: false, encoding: .utf8)
}
Upvotes: 11
Reputation: 20088
I ran into an issue with a document-based iOS app where I couldn't save or open documents on the device. The problem was that I had never created a document on the iPad I was using so the On My iPad location wasn't available.
The fix was to create a document in one of Apple's iWork apps and copy the document from iCloud to the device. After creating a document on the device, I was able to save and open documents in my app.
Upvotes: 0