SpecialFolder issues

I can write to SpecialFolder.Documents, but not SpecialFolder.ApplicationSupport or SpecialFolder.Temporary.

Has anyone else had issues with this?

Did you verify the folders exist first?
If not, you need to create them.


Is there a documentation available explaining which type to use in which case, or what their specific pros and cons are? In the Xojo documentation I find this list but maybe the Apple documentation has more on that?


Mobile has these properties:

  • ApplicationSupport
  • Caches
  • Documents
  • Temporary

Specific paths do not matter much with sandboxing, but you can use these locations to store files that your apps can access.

They’re defined here:

ApplicationSupport = NSApplicationSupportDirectory

Caches = NSCachesDirectory

Documents = NSDocumentDirectory

Temporary = NSItemReplacementDirectory

I know that’s not much help, but you’ll note that the name for Temporary is NSItemReplacementDirectory which gives you a clue.

I just went through the process of figuring out the declares for getting the temporary directory and apparently Apple now suggests a different way to get the temp directory than they did when we Xojo iOS was new.

Here’s a project with that function fleshed out: Download.

Note: Apple asks that you not forget to delete anything that you put in this directory when you are done.

1 Like

Ok. After doing a little digging and consulting of WWDC and some other resources it looks like the conditions for these folders on iOS are:

  • SpecialFolder.Temporary – Items in this directory should be truly temporary. It is not guaranteed to be the same across launches of your app and may even be deleted by the system when your app quits or is sent to the background. I suggest using the example I posted above for this until this gets fixed in the framework.
  • SpecialFolder.Caches – Items to make your app more efficient. It appears that this folder path does not change from launch to launch, but it may be cleared by the system when your app is not in the foreground to free up storage space in low storage conditions.
  • SpecialFolder.ApplicationData – Persistent items associated with your app which are not user-facing. Things like preferences.
  • SpecialFolder.Documents – Persistent items associated with your app which are user-facing. This folder may be visible to users in iTunes or Finder on macOS when the device is plugged in.

This is really helpful, Greg. Thank you for taking the time to investigate.
I’m downloading your project and will implement.

I believe I was using the filters with the proper intention. While SpecialFolder.Documents was working it didn’t feel right to put the preferences there.

As long as you don’t enable FileSharig Documents won’t be available in the finder or iTunes.

I’d expect preferences to be in ApplicationData unless you really want users to be able to access them someday.

I agree. It just wasn’t working.
I’ll try to update with your code samples.

So you can see the contents of SpecialFolder.Documents? From the Finder with phone plugged in? I am not see it. Any hints?

you have to click on the FIleSharing capability.

Thanks. But the app itself is not showing up in the finder window…

And you are USBing it not just using your network?
Is the sidebar visible?

It’s odd you are having trouble with this. Could it be an OS version issue? Can you see the device in iTunes?

Thank you sir! I had to reload or close window and select phone again. Appreciate the patience and have a great weekend!

1 Like

I’ve been putting database files in SpecialFolder.ApplicationData. This is all user data, but it makes no sense to allow access outside the app. Is this correct?

I tend to put read-only files in ApplicationData, like a database that populates a large table that the user selects from.

I put user-generated data in Documents (using JSON these days) which will be read back into the app upon a complete restart.

Did you ever get app to read/write to SpecialFolder.ApplicationSupport ? I can read and write to SpecialFolder.Documents but same code switching to SpecialFolder.ApplicationSupport does not run.

You should always test if the folder exists before using it.

Var folder As FolderItem = SpecialFolder.ApplicationSupport

If folder.exists = false then
End if

You are spot on as usual the folder was not there. It seems Documents has always been there but I guess better start checking for that too.

On a side note it looks like a folder is created named “Application Support” there is a space where in the call out it is one word. Wonder how that happens?