Best place to store app-settings

Hi,

i store my app-settings in SpecialFolder.ApplicationData.child(“myapp”). This results in /users/my-username/library/application support/myapp.

Works all fine. But now i try to make my app ready for the app store and it seems, that the signed and sandboxed app has no access to this folder.

At start, my app first checks if the app.json file with all the app-settings is there and loads it. But this does not happen with the signed app.

Where do you store things like settings (user-specific), sqlite-databases and so on in your app store ready apps?

This is what Apple says about it:

Michael

Within the MAS version, SpecialFolder.ApplicationData returns a different, sandboxed folder and that’s where you end up reading and writing.

I think the only way to get your MAS and non-MAS versions to share the same folder is to sandbox the non-MAS version too, but others can speak with more authority on this.

Right okay, are you sitting down?

#1 You can use your method and the Application Support folder, however what you’re doing wrong is that it needs to be the bundle identifier of the application and not it’s name.

SpecialFolder.ApplicationData.child( "com.mysite.myGreatApplication" )

#2 However storing files in this folder, does indeed store files on one place for the Sandboxed version of the application, and other place for the non-sandboxed version. The Sandboxed application (by default) cannot access the unsandboxed files.

There’s a bunch of ways how you can work around this, but none of them are perfect.
#A Use NSDefaults, the OS will then automatically migrate the settings from the non-sandboxed application into the sandboxed version, when it is first run. However you need to manually move the data back.

#B Use container-migration (configured within App Wrapper), with this you can specify which files you want moved into the Sandboxed version when it is first run. Again, you need to manually move them back if the user reverts to a non-sandboxed version.

#C Use a temporary entitlement that will allow the Sandboxed application to access the existing data. It’s not difficult, but you have to manually build the path (as specialfolder.applicationData points to the sandboxed only). The only difficulty is that Apple really don’t like allowing apps on the App Store with temporary Entitlements and you might have difficulty getting it approved.

And what does that mean for multi-platfom? I use the Specialfolder.ApplicationData also for Windows. Can i use the bundle identifier there as well?

No problem.

But on windows build settings there is no bundle identifier.

Nothing prevents you from creating a folder called “com.mycompany.myapp” …

I have several apps both in the MAS and under Windows that use the Mac bundle identifier for the preference subfolder that way.

ok. looks kind of unusual. maybe i go with

  #if TargetWin32 then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("UniFormis").Child("uniformis.json")
  #elseif TargetMacOS then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("com.bytemasters.uniformis").Child("uniformis.json")
  #endif

Can i check by code if the app is sandboxed?

[quote=175082:@Michael Bzdega]ok. looks kind of unusual. maybe i go with

  #if TargetWin32 then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("UniFormis").Child("uniformis.json")
  #elseif TargetMacOS then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("com.bytemasters.uniformis").Child("uniformis.json")
  #endif

Can i check by code if the app is sandboxed?[/quote]

A sandboxed app has it’s file structure within /Library/Containers. So you can check for the SpecialFolder.ApplicationData path. If it starts with “/Library/Containers”, you know it is sandboxed.

Thanks, found it already. Seems to works fine.

It is not to easy to get your first app into the app store…

[quote=175088:@Michael Bzdega]Thanks, found it already. Seems to works fine.

It is not to easy to get your first app into the app store…[/quote]

Not it is not, but once you have done it, the following apps will be much easier.

So i’m getting closer… The Application loader comments, that there are 2 Icons in ICNS-Format missing in the Bundle. How do i insert them with Xojo or App Warapper 3?

Which sizes are missing ? With 2015R1, you can place all sizes including 1024x1024 directly into Xojo (click App, then Icon).

App Wrapper 3 lets you add the icon in the dialog where you set up the preferences for tha pp, in the upper left corner. It should take care all needed icon sizes for you.

I now have added the 1024x1024 icon in Xojo and the Application-Loader completes.

Thanks.

[quote=175082:@Michael Bzdega]ok. looks kind of unusual. maybe i go with

  #if TargetWin32 then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("UniFormis").Child("uniformis.json")
  #elseif TargetMacOS then
    Dim f as FolderItem = SpecialFolder.ApplicationData.child("com.bytemasters.uniformis").Child("uniformis.json")
  #endif

Can i check by code if the app is sandboxed?[/quote]
This right here is why I created the TPSpecialFolders module. One can access your application data cross platform with one statement (as well as a myriad of other useful locations.) You might find it very useful :slight_smile:

Thanks, Tim.

Sorry, I forgot about your module!