I have a framework. Some things need to be stripped out to deal with Mac app sandboxing when the framework is embedded in sandboxed apps. Now I know I could create another target for the framework to use for sandboxed apps, but I kind of don't want to .
Right now, I just have the main sandboxed app set an environment variable in main, which corresponds to a string constant declared publicly by the framework. The framework simply looks for the prescense of this environment variable, if it's there, it deals with the sandbox, if it's not, it assumes the app isn't sandboxed.
Is there any official, reliable API to determine if the app is sandboxed at runtime? I did search around, found some code that does this, though using the code was discouraged.
On macOS you can get your code signing entitlements using
SecCodeCopySigningInformation
.
This post has an example. You can then look in the entitlements for the
com.apple.security.app-sandbox
key.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"