I am testing file access on macOS Big Sur Xcode Obj-C with a sandboxed app. Because the app is sandboxed, I had to give read/write access to the folder my app writes files to - in this case the user's Music Directory.
This is located at Targets / Signing & Capabilities in the Info Tab under App Sandbox and File Access Type.
My app is writing files using:
NSString* fileLocation = [NSString stringWithFormat:@"%@/Music/Sample Files", NSHomeDirectory()];
This all works file. My sandbox app has no problems working with files within the user's /Music/Sample Files/ folder.
My question is: if the user has moved their default Music folder location (which I believe is an option in macOS?) I don't think this would worlk. Since my app has ~/Music/Sample Files
- how can I write it so that it would still work if the user has moved their default Music Folder to somewhere else?
Bonus question: Why are the file access options so limited in the File Access Type for a sandbox app? It seems to be limited to Downloads / Pictures / Music / and Movies folders. Shouldn't the user's Documents folder (at the very least) be included in this list?
OK so I believe Music is a folder that can't be removed even if a music library is moved via the Music app. I guess if a music library is moved or changed, the default Music folder will still remain and usable by the app.
Therefore,
NSString* fileLocation = [NSString stringWithFormat:@"%@/Music/Sample Files", NSHomeDirectory()];
Should work regardless?
https://support.apple.com/en-lb/guide/music/mus69248042d/mac
https://apple.stackexchange.com/questions/100341/is-it-possible-to-remove-or-delete-the-music-folder