Why is the app behaving differently on your Mac?
I noticed that the app has in the System Settings -> Privacy and Security -> Files and Folders -> the app -> Downloads folder enabled
Not sure if this was done manually in the past or as part of the installation and it somehow disappeared.
How to achieve your final goal?
The URL is within the sandbox. As explained above the app sandbox was configured in XCode and AppStoreConnect as well the privacy key to access the Downloads folder was added in Info.plist. See the attached images.
Regardless if the Downloads folder is a simlink or not the swift code snippet should be capable to open it.
It looks like that the NSWorkspace does not function properly.
It does not check the app sandbox for the Downloads folder and does not ask the user for permission to access it.
With regards B, I don’t think there’s a way to achieve your goal as specified.
Yes, there is. Voila the solution. Not the best, but at least it works as expected.
func shell(_ command: String) -> String {
let process = Process()
let pipe = Pipe()
process.standardOutput = pipe
process.standardError = pipe
process.arguments = ["-c", command]
process.launchPath = "/bin/zsh"
process.standardInput = nil
process.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)!
return output
}
let result = shell("open Downloads")
Conclusion
Apple should investigate how the NSWorkspace functions beneath.
My use case above should be working.
The documentation about the App Sandboxing still mentions entitlement files, which are nowhere to be found nor possible to be added anymore. Seems the entitlements have been moved to the AppStoreConnect. The docs online need some updating as well.