How to access user-provided audio file persistently in IOS
-
Hello,
I use Qt 6.4.1 to develop an IOS application with C++ and QML. I can open a sound file using the Qt file picker dialog and then I get the url to that sound file. For example, I get
file:///private/var/mobile/Containers/Data/Application/4557D5E4-68BA-4341-9F4F-2A07D5E87B4D/tmp/runsomething.App-Inbox/myaudiofile.wav
So I can at that moment load the audio file into the QAudioPlayer and it works and plays.
I then store this URL in a json file to later retrieve it. And the problem is that this seems to be a sort of temporary file url, because upon restart of my application, that URL does not work anymore.
So, my question is how to handle this? Do I need to copy it myself to my own dir that I can create for example under the "Library/Application Support" path?
/var/mobile/Containers/Data/Application/4557D5E4-68BA-4341-9F4F-2A07D5E87B4D/Library/Application Support/App
Or is there some other way? I saw this post which allows a user to share a file with your application and seems to copy it inside your apps' storage. Then probably it will not be a "tmp" file anymore and the link to that file will work even after application restarts. Is that how you should do it? I don't really like that approach and would like to avoid it if possible.
I read about app sandbox capability, but I can't seem to add it to my IOS project using xcode, it does not show up in the list of capabilities. So I'm stuck there now and think that would be a way to enable access to files permanently without having to copy them.
Thanks for any pointers or help!
Best regards -
I found the solution, so the answer is now on stack overflow: https://stackoverflow.com/a/76936616/1882056
Best regards,
-
M MetalMajor has marked this topic as solved on