iOS file access permission
-
I'm trying to access files in the downloads folder on iOS for both reading and writing. My application does this successfully on Android, but on iOS permission is not being granted. I added
NSDownloadsFolderUsageDescription
to the info.plist file, which according to the apple developer site should do the trick (https://developer.apple.com/documentation/bundleresources/information_property_list/nsdownloadsfolderusagedescription). But it's still not working for me.On android I had to add some extra code to explicitly trigger the app to request permission. Do I need to do the same on iOS?
-
hmm, I added that to my info.plist and it didn't help.
I'm not sure how the iOS filesystem works. I don't see a downloads folder on my iPad like I have on my android phone and my windows PC. I do see that some of the other apps on my iPad have their own data folders that I can browse using finder. Also, my app never asks me to grant permission to access the downloads folder.
In case it helps, my app uses QStandardPaths to choose the location. On iOS, I have success with opening files using QStandardPaths::AppDataLocation but not with QStandardPaths::DownloadLocation (both of these worked fine on android).
-
iOS security model is not the same as Android and it does not expose the system's ressources in the same manner.
Did you check the entitlements in Xcode ?
-
macOS and iOS are two different beasts. I think you should take a look at this:
https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories -
Before seeing this reply, I figured out that the reason it wasn't working is because the downloads folder at the path that came form QStandardPaths didn't exist. Now my app can read and write those files. However, I can't find it through the iPad browser or when I try to browse on my mac. I think that I can't find it because the the path I'm using now from QStandardPaths is part of the app's sandbox.
Anyway, I'll have to implement a file dialog to try your solution. Would QFileDialog do the trick?
-
QFileDialog uses the system dialog by default on systems that provide one. I am currently unsure that it will fit your use case but I haven't used it directly on iOS for a long time.
-
Did you already do Objective-C++ ?
-
@kgregory Even this topic is old, I've stumbled over it and had similar issues: For me it seems that you'll still stay in the sandbox anyway. The Dialogs might help to get access to outside folders.
This answer is giving a very usefull example on native code: https://stackoverflow.com/questions/46588201/no-files-found-on-ios-devices-qt-creator-c-qstandardpathsstandardlocationsq
With the use of the simulator you can check the filesystem of iOS and have a peek on what is going on. I've found that the native code of the example also does not leave the sandbox. It's about the project settings (namely the Info.plist's UIFileSharingEnable bool (true)) that is exposing your sandbox at least to the iOS file app.