I am trying to use SpecialFolder in an iOS app to save the persistent data for the app and do not see ApplicationData among the options. Not sure if ApplicationData is something new for iOS 14 / 15?
The Language Reference shows the following for Mobileā¦
ā¦but again, this does not come up in the code completion.
Not sure if this a bug or there is no ApplicationData like what you suggest.
Screen grab of what you suggested is below:
Iām still in a fog here, maybe thereās something Iām missing.
Do you need ApplicationData specifically? You could use ApplicationSupport or even keep it in documents folder (depending on what it is).
Nah, I just need a place where persistent data can live. I just noticed that the language ref uses ApplicationData specifically in the sample code, and didnāt know which one was apropos for iOS.
Iām going to try ApplicationSupport and see how that goes.
I am boggled hereā¦ I tried a folder that appears to be possibly user-facing - Documents - and the āmedsā folder does not appear when I open Files and browse to On My iPhone, the folder exists somewhere, but apparently not within the scope that Files will allow me to see?
Any help understanding this would be appreciated. Maybe this is because I am running an emulator on the Run command?
Did you try turning on file sharing on from Xojo and then build the app?
Once you do that you can connect your iPhone to the computer and see the document folder from the finder.
Did not realize that was an option. Had zero clue. I will definitely try that.
Uhm. Why canāt I see that folder from the emulator?
ApplicationData and ApplicationSupport are equivalent. Desktop projects use ApplicationData, mobile projects use ApplicationSupport. But they serve the same purpose.
Is the emulator supposed to not write anything to ApplicationSupport? Or is that possibly a bug? Iām gonna try this project with the newest version of Xojo to test to see if this is an r2 vs r3 thing. I do know that a number of bugs were fixed in r3.
[EDITED TO ADD:]. I just tried it on r3 and ApplicationSupport still wonāt reflect a folder being written to it. But, the alleged āDocumentsā folder does kick back True on the meds folder existing on second check after creation.
The simulator writes to a simulator folder not your macos ApplicationSupport folder.
you can
system.debuglog myFolderitem.NativePath
to see where it writes to
I just tested a Development build on my actual iPhone and it keeps acting like it never created the meds folder when testing on my actual device. Iām beginning to wonder if there is some setting that allows me to write to the ApplicationSupport folder. Or a bug. I am using r3 the latest published build.
[EDITED to add:]
When I assign the SpecialFolder.Documents to receive the file folder, the creation of the folder does stick while I am in the app. It continues to react as if this folder does exist after I swipe-close the app and restart it, so apparently there is indeed persistent dataā¦ I just cannot find where this Documents folder is, and I cannot navigate to it using the Files app on my iPhone.
Thatās correct. It is not a shared documents folder like you would get on a Mac. iOS apps are sandboxed, so youāre getting a documents folder that is specific to your app. The files app cannot see it, and there is no reason to know its true path. The same is true for ApplicationSupport. The only difference is the kinds of files you are expected to store in each.
Iād love to solve your issue with ApplicafionSupport, but I donāt know why youād see what youāre seeing.
Well, the sandboxing does make sense now. When I hook my iPhone up and synchā¦ and see the Files, meds is indeed in a nested directory listing named for the app. So, yeah, okay. I get it now.
I have no idea why I see what I am seeing regarding ApplicationSupport, to be honest. With my luck, Iāve probs found a bug?
Methinks I need to get some sleep. Itās now Friday, 5.36am over here on the east coast (USA).
Ugh, Iāve been trying to sort this bug all day (and night).
I can confirm that the SpecialFolder.ApplicationSupport directory is no longer writable on the iOS simulator. Please file a bug report and weāll get this looked at. It could be that Apple wants you writing that stuff elsewhere, but I havenāt found that info yet.
In my test, the folder doesnāt exist
if (in this case) you create it then itās all ok
Bug report is now alive on Feedback system.
<https://xojo.com/issue/66677>
Thank you so much for verifying this to be a bug.
right. itās not that it isnāt writable thoughā¦ itās that it doesnāt exist. if you call CreateFolder on the returned folderitem it should work just fine.
To re-iterate:
Although on the iPhone there is a files app and what looks like a documents folder,
your app cannot (as far as I know) write to it.
Specialfolder.documents gives you a folder that is specific to your app only.
āFilesā cannot see into it.
You can make the folder visible to other things by setting the File Sharing attribute.
If you do that, you will be able to see your documents folder and the meds subdirectory when plugging your device into a Mac or Windows machine.
The whole system is frankly stupid, but considered āsafeā
Is there an app specific folder that doesnāt get deleted when the app is uninstalled by the user or that iOS recovers when the user reinstalls the app?