SpecialFolder issues

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?

Screen Shot 2021-11-18 at 9.57.20 PM

The Language Reference shows the following for Mobileā€¦
Screen Shot 2021-11-18 at 10.01.37 PM
ā€¦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:Screen Shot 2021-11-18 at 10.05.45 PM
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).

1 Like

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.

1 Like

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?
Screen Shot 2021-11-19 at 1.45.17 AM
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.

1 Like

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.

2 Likes

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. :thinking:

The simulator writes to a simulator folder not your macos ApplicationSupport folder.
you can

system.debuglog myFolderitem.NativePath

to see where it writes to

1 Like

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. :thinking:

[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.

1 Like

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? :woman_shrugging:t2:

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

1 Like

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ā€™

1 Like

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?