Search code examples
c++objective-ccocoaclangsandbox

ANY possible way to run the clang compiler from a Sandboxed app?


OK, the question is fairly straightforward.

I have a sandboxed OSX app.

I want the user to be able to compile some C code (whatever he inputs).

But whenever I'm attempting a call to:

/usr/bin/env clang /the/path/to/the/source.c

I'm getting the following error in the logs:

xcrun: error: cannot be used within an App Sandbox.

Is there any way to circumvent this?


P.S. I've successfully done pretty much the same thing with Ruby, Python and PHP.


Solution

  • If you want to keep your app sandboxed you could try to add a Temporary exception key to your entitlements file:

    com.apple.security.temporary-exception.files.absolute-path.read-only

    More information on that here

    Another way to achieve it would be the more troublesome way of creating an helper app (XPC-service) which is not sandboxed. There are also some details about XPC-services here.