Post

Replies

Boosts

Views

Activity

Reply to Error `sandbox_extension_issue_file` when resolving security-scoped bookmark of file under `/System/Volumes/Data/...`
Just a guess: Since /System/Volumes/Data/ contents are merged into /, you need to replace those paths accordingly (i.e. replace that long prefer in a path with the root path), and then you'll probably get permission. If that works, then I suspect that the Sandbox path access validation code has not been updated to match these aliased paths when volume groups were introduced. I've run into several related issues, outside sandbox, and need to employ similar work-arounds. One would hope that Apple would provide APIs for determining the members and paths of volume groups, and conversion methods, but that's not happening (see also https://stackoverflow.com/q/63876549/43615) Oh, and if you don't like the path replacement method, you could also try getting the CanonicalPath instead - that should also point to the regular path, but take more time than the simple string replacement. If you only do this for a few bookmarks, that shouldn't have an impact and is safer. In fact, there are two ways I use in my apps to get the canonical path. I don't remember which one works, so try them both: Get the fileReferenceURL This code (see also https://stackoverflow.com/questions/64720189): NSString* canonicalFilePath (NSURL *url) { // Caution: Will expand /var/ into /private/var/ NSString *result = nil; if (@available(macOS 10.12, *)) { NSString *cpath; if ([url getResourceValue:&cpath forKey:NSURLCanonicalPathKey error:nil] && cpath) { result = cpath; } else { result = url.URLByResolvingSymlinksInPath.path; } } else { result = [[url fileReferenceURL] filePathURL].path; } return result; }
Topic: App & System Services SubTopic: General Tags:
Jan ’22
Reply to How detect SDK version
To those who need an answer on how to conditionally compile depending on the used SDK version, here's what I found to work: #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 // ... compiles only when using the macOS12.0 SDK (or later) that comes with Xcode 13.1 #endif
Topic: Programming Languages SubTopic: General Tags:
Nov ’21
Reply to How detect SDK version
I am disappointed that there is no actual answer to the question in the title. I need an answer to this and this is the first hit on Google. Yet, all that I see here is suggestions for solving the specific issue but not the question in the title. To answer Quinn's question: In my case, I need to keep my code compatible with various SDK versions (for various reasons that are valid but shouldn't need to be justified here), so I need to add conditional code depending on the SDK version. And since it's a compile time issue, I cannot use @available() here, either. So I really need to know which SDK I'm compiling under.
Topic: Programming Languages SubTopic: General Tags:
Nov ’21
Reply to Error `sandbox_extension_issue_file` when resolving security-scoped bookmark of file under `/System/Volumes/Data/...`
Just a guess: Since /System/Volumes/Data/ contents are merged into /, you need to replace those paths accordingly (i.e. replace that long prefer in a path with the root path), and then you'll probably get permission. If that works, then I suspect that the Sandbox path access validation code has not been updated to match these aliased paths when volume groups were introduced. I've run into several related issues, outside sandbox, and need to employ similar work-arounds. One would hope that Apple would provide APIs for determining the members and paths of volume groups, and conversion methods, but that's not happening (see also https://stackoverflow.com/q/63876549/43615) Oh, and if you don't like the path replacement method, you could also try getting the CanonicalPath instead - that should also point to the regular path, but take more time than the simple string replacement. If you only do this for a few bookmarks, that shouldn't have an impact and is safer. In fact, there are two ways I use in my apps to get the canonical path. I don't remember which one works, so try them both: Get the fileReferenceURL This code (see also https://stackoverflow.com/questions/64720189): NSString* canonicalFilePath (NSURL *url) { // Caution: Will expand /var/ into /private/var/ NSString *result = nil; if (@available(macOS 10.12, *)) { NSString *cpath; if ([url getResourceValue:&cpath forKey:NSURLCanonicalPathKey error:nil] && cpath) { result = cpath; } else { result = url.URLByResolvingSymlinksInPath.path; } } else { result = [[url fileReferenceURL] filePathURL].path; } return result; }
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to How detect SDK version
To those who need an answer on how to conditionally compile depending on the used SDK version, here's what I found to work: #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 // ... compiles only when using the macOS12.0 SDK (or later) that comes with Xcode 13.1 #endif
Topic: Programming Languages SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to How detect SDK version
I am disappointed that there is no actual answer to the question in the title. I need an answer to this and this is the first hit on Google. Yet, all that I see here is suggestions for solving the specific issue but not the question in the title. To answer Quinn's question: In my case, I need to keep my code compatible with various SDK versions (for various reasons that are valid but shouldn't need to be justified here), so I need to add conditional code depending on the SDK version. And since it's a compile time issue, I cannot use @available() here, either. So I really need to know which SDK I'm compiling under.
Topic: Programming Languages SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’21