appstore-sandbox

How do I get the users home directory in a sandboxed app?

两盒软妹~` 提交于 2019-11-27 13:39:01
问题 NSHomeDirectory() is retuning my sandbox root, not my home directory. [@"~" stringByExpandingTildeInPath] is doing the same thing. This /Users/username/Library/Containers/appID/Data is what's being returned. How do I get /Users/username/ ? 回答1: If you want the path to the user's real home directory you can use: char *realHome = getpwuid(getuid())->pw_dir; Full example: #include <unistd.h> #include <sys/types.h> #include <pwd.h> #include <assert.h> NSString *RealHomeDirectory() { struct passwd

App sandbox: how to allow XPC service to read file that user opened in parent app?

有些话、适合烂在心里 提交于 2019-11-27 13:15:06
问题 I have a simple Cocoa image preview app. The user selects a file using an NSOpenPanel and the app generates a preview image using the Quick Look API. I'd like to move the preview generation into a separate XPC service. Without app sandboxing everything works fine, but after enabling app sandboxing for the parent app and the XPC service, the XPC service is denied read access to the user selected file . The parent app is allowed to read the file (because it was selected through an NSOpenPanel).