Packages - how to put folder into user/library/application Support

Hi there… I’m ready to deploy (not to the app store).
In the past I’ve been using packages. Stupidly, I can install a folder that my app cannot really access in the root/Library/Application support. That is not where it should really go (for obvious reasons)… it should be in
user/Library/Application Support.
I can set my app, and fonts to the correct places.
Can somebody tell me the steps to put a folder into my username/Library/Application support?
A picture would be helpful?
Cheers!

at special folders it seems to be named as ApplicationData in /Users/UserName/Library/Application Support
https://documentation.xojo.com/api/files/specialfolder.html#api-files-specialfolder-usage

Try

~/Library/Application Support/

the ~ is used as placeholder for the username.

Does this mean that in the payload under user I make a new folder called ~ and then under that ianother folder called. library under that another folder called application data - then drag my folder into that?

No, all those already exist for your account on macOS.

1 Like

I created the “Created Folder” in packages, and referenced a folder from my machine in it.
Be careful to ensure that the permissions are correct for any items within the referenced folder. IE make sure “Everyone” has the correct permissions. I have had installs where I could not access files within a folder.

I tried - what did I get wrong? The folder did not install anywhere as far as I can see… Not in MacOS/Library/Application Support (where is not where it should have gone)
and not in
sean/Library/Application Support (where i wanted it to go)
Here’s a screenshot

Honestly, its a lot easier to get the app to make such a folder and populate it on first run, if it is not present.
I pack stuff like this in an embedded zip file.
Packages have a nasty habit of putting your stuff in unexpected places - it will even install an update into the Trash if you deleted an existing app before installing!

3 Likes

Is it possible to add the folder inside the app (in the folder inside the app). Then I could move it during the first run to the proper folder. Do we have some code that incudes a progress bar along with the folder move item that I could show at first run?

You should be able to run a post-installation .sh script, under Scripts Tab, to move folders from your files installed in applications to Application Support. Or move during first run. I have done both.

Xojo has no ‘copy folder’ command, although I have a method somewhere.
What I do:

Does my support folder exist?
If no then 
   create such a folder
    copy individual files from resources to that folder
end if

The files to be copied can be dragged into the IDE and they will be in the resources folder of your app… you don’t even need to get them there with a post build copy action.

API1 syntax…

Public Sub Copyfolder(foldernamefrom as folderitem,foldernameto as folderitem)
  Dim i as integer
  if FoldernameFrom.Directory = false then return
  if foldernameto.exists = false then 
    FoldernameTo.CreateAsFolder
  else
    try
      deletefolder foldernameto
      FoldernameTo.CreateAsFolder
    catch
    end try
  end if
  
  for i = 1 to FoldernameFrom.Count
    
    if FoldernameFrom.item(i).Directory then
      try
        dim subfolder as FolderItem = FoldernameTo.child( FoldernameFrom.Item(i).Name)
        CopyFolder (FoldernameFrom.item(i),subfolder)
      catch
      end try
    else
      try
        dim subfile as FolderItem =  FoldernameTo.child( FoldernameFrom.Item(i).Name)
        FoldernameFrom.Item(i).CopyFileTo (subfile)
      catch
      end try
    end if
  next
  exception
End Sub

What about FolderItem.CopyTo? It handles both files & folders.

If so, great.
(API2, is it? )

Sounds like a better bet if it does the trick, and the OP copies a folder structure into the resources folder.

I use a zip file in the resource folder to expand into specialfolder.applicationdata, after I’ve checked if the target already exists.

Can be easily done with pure Xojo code and has the smallest possible footprint in app size.

1 Like

Yes, and that also provides a backup plan in case the user gets into the folders and starts deleting things. Don’t ask me why, they just do, I think it is something built into their DNA.

1 Like

I think the best way is to see if the resource folder exists in application data. delete it (using the deletefolder routine), then MOVE the new folder into place. It move it out of the interval file structure of the app. We care talking about Mac here!

Copy, dont move the folder. When moving something from inside your app you will change the checksum of your app and gatekeeper will block it.

1 Like

I tried installing the resource folder into the same as the executable. I really need to move it otherwise it’ll keep rewriting the application data folder every time it runs if I just copy it.
I know that it can’t be moved from the resource folder as the gatekeeper will block it (see above)…
I tried using
f=App.ExecutableFile.parent.child(“My resource folder”)
So I could move it from there… However, I can’t seem to make that work.
The goal is to use packages to install it somewhere where I can move it to my user applicationdata folder. Any ideas?

Of course, you can copy data from the resources folder to Application Support. The folder above is NOT the resources folder of your app.

Files in the resources folder can be access the following way:

iconPathLight = SpecialFolder.Resources.Child(some file)

You are still missing very basic information. Make a simple example, get that to work. Then do something more complicated.