Testing Windows application on OS X for first time

Hi guys,

I’ve started testing an application written in Xojo for Windows on the OS X platform, and are hitting the first hurdle. On Windows I create a folder for my application’s data using the SpecialFolder.SharedApplicationData as follow:

  DataFolder = SpecialFolder.SharedApplicationData
  
  if not DataFolder.Child("Zoclee").Exists then
    DataFolder.Child("Zoclee").CreateAsFolder
  end if
  DataFolder = DataFolder.Child("Zoclee")
  
  if not DataFolder.Child("SmartData").Exists then
    DataFolder.Child("SmartData").CreateAsFolder
  end if

This code runs fine on Windows, however I’m getting an NilObjectException on the following line:

  if not DataFolder.Child("SmartData").Exists then

So my question is, what is the best practice on OS X when it comes to storing data created during runtime by an application. Is the SpecFolder.SharedApplicationData the right place to do so? and if so, why can’t I create a folder in it?

FWIW, when I debug the app, the native path of SpecialFolder.SharedApplicationData is

/Library/Application Support

Any pointers or tips that will set me on the right path when it comes to storing application data on OS X will be appreciated.

You really shouldn’t use SpecialFolder.SharedApplicationData on either platform. (you should use SpecialFolder.ApplicationData instead)
On Mac you need Administrator privileges to write into it. If you’re targeting the app store, my bet is you will have difficulty with the review team.

Please use TPSF to access your application’s data folder, it will use the best location on both Mac and Windows.

https://github.com/devtimi/TPSF

Just change

DataFolder = SpecialFolder.SharedApplicationData

to

DataFolder = TPSF.AppSupport

and you are good to go.

Great stuff, thank you Tim.

A BIG thumbs up for your solution Tim. Just tested my app on OS X again and it is now running smoothly without the previous errors.

:slight_smile:

This community rocks.