I know that similar questions have been asked but I couldn't find anything that solves my problem.
In my case, I have developed an iOS app (Xcode 13.4) to import and parse data from a CSV file that I pick using an UIDocumentPickerViewController
. Everything works fine on simulator, but when I run the app on my iPhone, the moment I pick a file and try to parse it, my app crashes with the error The file "test.csv" couldn’t be opened because you don’t have permission to view it
. I have added every permission that are related with documents access in my Info.plist
as follows:
<key>NSFileProviderDomainUsageDescription</key>
<string>Description</string>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>NSDesktopFolderUsageDescription</key>
<string></string>
<key>NSDownloadsFolderUsageDescription</key>
<string></string>
<key>NSFileProviderPresenceUsageDescription</key>
<string></string>
<key>NSAppleMusicUsageDescription</key>
<string></string>
<key>UIFileSharingEnabled</key>
<true/>
<key>NSDocumentsFolderUsageDescription</key>
<string>Description</string>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
But nothing works. Am I missing something? Thanks in advance!
CodePudding user response:
In case someone is interested, I've been able to solve it by calling url.startAccessingSecurityScopedResource() in the document picker before actually accessing the file. Hope this helps!