Accessing App Support with sandboxing

This embarrassing little bug came to my attention today. I created a Templates folder in my AppSupport folder that is linked to a corresponding Templates menu. The menu shows the contents of the folder and updates when the folder changes. That part works fine.

When a user wants to save something as a Template, they choose “Save To Templates” and are shown a Save As dialog so they can name the file, and the dialog points at the Templates folder. That part also works.

Except they are not the same Templates folder…

Because of sandboxing, the Templates folder that my menu looks at and updates from is the one in Library/Containers/…/Application Support, but when the user is directed to save to the Templates folder, or chooses “Show Templates Folder”, they are directed to the one in Library/Application Support.

Any recommendations on the best way to reconcile this? Or do I just hard-code different paths for my MAS version vs. the “normal” version?

How do the templates get into the ones in /Library/ApplicationSupport to start with ?

If you have sandbox enabled in your application, you can’t access the folder “/Library/ApplicationSupport” or /User//Library/ApplicationSupport". You have only access to /Library/Containers/<Your Application Bundle Itentifier/Library/ApplicationSupport/

Are you using the Xojo OpenDialog to save? I complained about this same bug awhile ago. In a sandboxes app, SpecialFolder.Application data points to the correct sandboxed location. But when passed to openDialog.initialDirectory, it points to the wrong (unsandboxed) location. I was forced to work around this but saving without user intervention.

This. There is also an option to download templates from my web site that happens without user interaction, so those go into the sandboxed location too. But when I use FolderItem.Launch to show the folder, it opens the non-sandboxed location, so I’m thinking this is a system thing, and there is an “approved” way to deal with it.

Indeed I’d agree with you, I’ve seen weirdness even with Xcode opening the wrong file, double clicked on the one in the app container, to be shown the one in the library folder…

If you’re saving their template to a specific folder, could you just give them a dialog to name the file?[quote=39114:@Roger Clary]Are you using the Xojo OpenDialog to save? I complained about this same bug awhile ago. In a sandboxes app, SpecialFolder.Application data points to the correct sandboxed location. But when passed to openDialog.initialDirectory, it points to the wrong (unsandboxed) location. I was forced to work around this but saving without user intervention.[/quote]
Can you give us the feedback link?