Search code examples
cocoacommand-linesandbox

How to sandbox a command line tool?


I've a simple unix tool made by me that launches the main cocoa app from a shell.

I need to sandbox it but when I run it, it crashes with error "Illegal instruction: 4", on console.app I can see the following error message

Sandbox creation failed: Container object initialization failed: NIL container info object with no error description for visdiff

The file is correctly signed with codesign.

I've read the post Mac OS app, sandbox with command line tool? but it doesn't help


Solution

  • I was having this exact problem, and it went away when I added an embedded Info.plist.

    Try these clang flags (assuming you have info.plist in the build directory):

    -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __info_plist -Xlinker info.plist