So I'm trying to maintain free open-source macOS tools. These two tools are sandboxed and hardened runtime. One is an image viewer that writes out a perftrace file into the sandbox folder (in Containers). Then another app tries to open that perftrace file (json).
When the perftrace file is opened in Xcode (signed and notarized), the file opens fine the first and all subsequent times.
When the opening app is kram-profile (signed not notaraized), the file opens once and then nothing can ever open it again. The app has attribute com.apple.quarantine set on it.
The only workaround to then open this file is to remove the attribute
xattr -d com.apple.quarantine <filename>
This is my tool build in Xcode, and having to sign let alone notarize an app is a large amount of complexity. Also this app is available on github.
this just seems to be the default behavior of turning on the App Sandbox.
Right. And for the reasons that you outlined.
If you repeat your test with a file using the .txt
extension, do you still see the problem?
In general, quarantine doesn’t apply to documents. However, some document types could contain code, and thus are checked by quarantine. For example, on my Mac I created two documents, test.txt
and test.md
, and quarantined them in the same way. The test.txt
document always opens fine, but the test.md
document bumps into the issue you’re seeing [1].
I’ve never explored this space in detail, so I’m not 100% sure what all the rules are. Hence the test I’ve suggested above.
I guess the lesson is to only enable hardened runtime and app sandbox in an App Store or otherwise distributable build, and not in the debug/release builds.
That seems like it’d be a mistake in general. The hardened runtime and App Sandbox both significantly change the behaviour of your app. If you only enable them when you ship, you are likely to miss problems. In this case it seems like it’d be better to create a build just for profiling. Alternatively, you can remove the quarantine in this case.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Markdown can contain HTML which is code as far as quarantine is concerned.