MacCatalyst and the User's Documents Folder

I have a SwiftUI-based universal app which creates a file that it stores in documentsDirectory. On iOS/iPadOS, this file is stored in the application's Documents directory and is accessible via the Files app.

On MacCatalyst, this operation does the same thing — it creates the file and stores it in ~/Library/Containers/<app directory>/Data/Documents. However what I want is for the document to be stored in ~/Documents, so that it is easily accessible to the user.

How can I do that? I'd like it to occur without (for example) having to show a SaveFile panel...

Is your app sandboxed? If so, the only way is to show a NSOpenPanel and ask the user to select the Documents folder (or any other folder).

Showing an open panel and asking the user where to put the files is the best option even if the app is not sandboxed. Please don't litter the Documents folder with random things by default.

MacCatalyst and the User's Documents Folder
 
 
Q