I have existing macOS application
the application is distributed via pkg
now I need Mac App Store version
I store application data in ~/Documents/MyApp
ideally i wan’t to keep using same folder
1. With pkg it’s rather simple, application asks for ~/Documents permission once
<key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>
<array>
<string>/Documents/</string>
</array>
2. but for sandbox it’s forbidden as I see
i can only use:
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
now app creates folder in ~/Library/Containers/com.my.app by default
- Is it possible to request same permission once and continue using ~/Documents/MyApp folder?
- Better to use Migration using container-migration.plist?
- Any other possible options?
Thanks in advance!
I tried to use NSOpenPanel, after selection it’s fine
But it looks like User need to select folder at each application launch?
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
openPanel.prompt = @"Select";
openPanel.message = @"Please select Documents folder";
openPanel.canChooseFiles = false;
openPanel.allowsOtherFileTypes = false;
openPanel.allowsMultipleSelection = false;
openPanel.canChooseDirectories = true;
openPanel.directoryURL = [NSURL URLWithString: @"~/Documents/"];
NSModalResponse response = [openPanel runModal];
if (response == NSModalResponseOK) {
NSLog(@"OK: %ld %@", response, [[openPanel URLs] lastObject].absoluteURL);
//possible to use/create MyApp folder
} else {
NSLog(@"Error: %ld", response);
}