xcodemacosgccsandbox

How to build Sandboxed app without XCode?


How to build Sandboxed app without XCode? I mean I'm using gcc Make to build my applications and own system for creating app bundles. But how can I enable the Sandbox without using XCode and option it's Sandbox option?

There's tut about Sandbox, but I can't find anywhere informations about enabling Sandbox, but still no about SB without XCode.. Anyone can help? http://developer.apple.com/library/mac/#documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxQuickStart/AppSandboxQuickStart.html#//apple_ref/doc/uid/TP40011183-CH2


Solution

  • It's pretty easy to code-sign your application outside of Xcode. Simply create your entitlements in a separate plist file like this:

    <?xml version="1.0" encoding="utf-8"?>
    <plist version="1.0">
        <dict>
            <key>com.apple.security.app-sandbox</key>
            <true/>
        </dict>
    </plist>
    

    Once you have it, simply issue this command to code-sign your app bundle and enable sandboxing, by making it part of the entitlements:

    codesign -s - -f --entitlements /path/to/entitlement.plist /path/to/YourApp.app/
    

    If you already code-sign with a certificate, just replace '-s -' above with '-s "3rd Party Macintosh Developer..." and use your developer certificate.