{"id":592,"date":"2013-02-05T12:29:26","date_gmt":"2013-02-05T04:29:26","guid":{"rendered":"http:\/\/xujiwei.com\/blog\/?p=592"},"modified":"2016-12-27T01:36:25","modified_gmt":"2016-12-26T17:36:25","slug":"embed-third-party-binary-in-sandboxed-mac-app","status":"publish","type":"post","link":"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/","title":{"rendered":"\u5728 Sandboxed Mac App \u4e2d\u5d4c\u5165\u7b2c\u4e09\u65b9\u53ef\u6267\u884c\u6587\u4ef6"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69d8bda382458\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69d8bda382458\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/#%E6%A3%80%E6%9F%A5%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E6%98%AF%E5%90%A6%E5%90%AF%E7%94%A8_sandbox\" title=\"\u68c0\u67e5\u53ef\u6267\u884c\u6587\u4ef6\u662f\u5426\u542f\u7528 sandbox\">\u68c0\u67e5\u53ef\u6267\u884c\u6587\u4ef6\u662f\u5426\u542f\u7528 sandbox<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/#%E7%BB%99%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E7%AD%BE%E5%90%8D%E5%B9%B6%E5%90%AF%E7%94%A8_sandbox\" title=\"\u7ed9\u53ef\u6267\u884c\u6587\u4ef6\u7b7e\u540d\u5e76\u542f\u7528 sandbox\">\u7ed9\u53ef\u6267\u884c\u6587\u4ef6\u7b7e\u540d\u5e76\u542f\u7528 sandbox<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/#%E9%97%AE%E9%A2%98\" title=\"\u95ee\u9898\">\u95ee\u9898<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" title=\"\u53c2\u8003\u8d44\u6599\">\u53c2\u8003\u8d44\u6599<\/a><\/li><\/ul><\/nav><\/div>\n<p>\u4e4b\u524d\u5f00\u6e90\u4e86 <a href=\"http:\/\/xujiwei.com\/blog\/2013\/01\/gitstatx-a-gui-for-gitstatx\/\">\u4e00\u4e2a gitstats \u7684 GUI \u5e94\u7528 GitStatX<\/a>\uff0c\u5728\u63d0\u4ea4\u5230 <a href=\"https:\/\/github.com\/ohdarling\/GitStatX\">GitHub (GitStatX)<\/a> \u4e4b\u540e\uff0c\u53c8\u51c6\u5907\u63d0\u4ea4\u5230 Mac App Store\u3002<\/p>\n<p>\u5728\u63d0\u4ea4\u5230 Mac App Store \u4e4b\u540e\uff0c\u51fa\u73b0\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u7a0b\u5e8f\u4e2d\u5305\u542b\u7684\u7b2c\u4e09\u65b9\u53ef\u6267\u884c\u6587\u4ef6\u6ca1\u6709\u7b7e\u540d\uff0c\u5bfc\u81f4\u82f9\u679c\u62d2\u7edd\u4e86\u63d0\u4ea4\u7684\u7a0b\u5e8f\u5305\uff1a<\/p>\n<blockquote><p>\n  <strong>App sandbox not enabled<\/strong> - The following executables must include the \"com.apple.security.app-sandbox\" entitlement with a Boolean value of true in the entitlements property list. Refer to the App Sandbox page for more information on sandboxing your app.<\/p>\n<ul>\n<li>GitStatX.app\/Contents\/Resources\/git\/bin\/git <\/li>\n<li>GitStatX.app\/Contents\/Resources\/gnuplot\/gnuplot<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u4f46\u662f GitStatX \u6240\u5305\u542b\u7684 git \u4ee5\u53ca gnuplot\uff0c\u5e76\u4e0d\u662f\u6211\u7a0b\u5e8f\u4e2d\u7684\u4ee3\u7801\uff0c\u4e5f\u6ca1\u6709 Xcode \u5de5\u7a0b\u53bb\u4f7f\u7528\u4e00\u4e2a entitlements \u6587\u4ef6\u6765\u6307\u5b9a\u5b83\u4e3a\u542f\u7528 sandbox \u72b6\u6001\u3002<\/p>\n<p>\u6240\u5e78\u5728\u7f51\u4e0a\u641c\u7d22\u7684\u65f6\u5019\uff0c\u627e\u5230\u4e86\u53ef\u4ee5\u4f7f\u7528 <code>codesign<\/code> \u5de5\u5177\u6765\u8fdb\u884c\u7b7e\u540d\u7684\u65b9\u6cd5\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E6%A3%80%E6%9F%A5%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E6%98%AF%E5%90%A6%E5%90%AF%E7%94%A8_sandbox\"><\/span>\u68c0\u67e5\u53ef\u6267\u884c\u6587\u4ef6\u662f\u5426\u542f\u7528 sandbox<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code>codesign --display --entitlements - .\/commandlinetool\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E7%BB%99%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E7%AD%BE%E5%90%8D%E5%B9%B6%E5%90%AF%E7%94%A8_sandbox\"><\/span>\u7ed9\u53ef\u6267\u884c\u6587\u4ef6\u7b7e\u540d\u5e76\u542f\u7528 sandbox<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5148\u5728\u547d\u4ee4\u884c\u5de5\u5177\u540c\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a entitlements.plist\uff1a<\/p>\n<pre><code>&lt; ?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt; !DOCTYPE plist PUBLIC \"-\/\/Apple\/\/DTD PLIST 1.0\/\/EN\" \"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\"&gt;\n&lt;plist version=\"1.0\"&gt;\n&lt;dict&gt;\n    &lt;key&gt;com.apple.security.app-sandbox&lt;\/key&gt;\n    &lt;true&gt;&lt;\/true&gt;\n    &lt;key&gt;com.apple.security.inherit&lt;\/key&gt;\n    &lt;true&gt;&lt;\/true&gt;\n&lt;\/dict&gt;\n&lt;\/plist&gt;\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u8bbe\u7f6e\u4e86 com.apple.security.app-sandbox \u4e3a true \u6765\u542f\u7528 sandbox\u3002<\/p>\n<p>\u7136\u540e\u4f7f\u7528 codesign \u8fdb\u884c\u7b7e\u540d\uff1a<\/p>\n<pre><code>codesign -s \"3rd Party Mac Developer Application: Your Name\" --entitlements .\/entitlements.plist .\/commandlinetool\n<\/code><\/pre>\n<p>\u8bb0\u5f97\u628a \"3rd Party Mac Developer Application: Your Name\" \u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u8bc1\u4e66\u540d\u79f0\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E9%97%AE%E9%A2%98\"><\/span>\u95ee\u9898<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5728\u7ed9 gnuplot \u7b7e\u540d\u4e4b\u540e\uff0c\u63d0\u4ea4\u5230 Mac App Store\uff0c\u82f9\u679c\u8fd8\u662f\u4f1a\u81ea\u52a8\u9a8c\u8bc1\u5e76\u53d1\u90ae\u4ef6\u8bf4 gnuplot \u6ca1\u6709\u7b7e\u540d\uff0c\u4e8e\u662f\u5728\u672c\u5730\u76f4\u63a5\u5bfc\u51fa GitStatX.app\uff0c\u5e76\u68c0\u67e5\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0 gnuplot \u7684 entitlements \u53c8\u6ca1\u6709\u4e86\uff0c\u4f46\u662f git \u7684 entitlements \u8fd8\u662f\u4fdd\u7559\u7684\u3002\u5728 gnuplot \u540c\u76ee\u5f55\u4e0b\uff0c\u6709\u4e00\u4e2a _CodeSignature \u76ee\u5f55\uff0c\u53ef\u80fd\u662f\u5728\u6253\u5305\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u5904\u7406\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u5c31\u628a gnuplot \u4e5f\u653e\u5230\u4e86\u4e00\u4e2a bin \u76ee\u5f55\u4e0b\uff0c\u7136\u540e\u518d\u6253\u5305\u5e76\u68c0\u67e5\uff0c\u53d1\u73b0 gnuplot \u5df2\u7ecf\u662f\u6b63\u786e\u7b7e\u540d\u5e76\u4e14\u4fdd\u7559\u6709 entitlements \u7684\u4e86\u3002<\/p>\n<p>\u5f53\u7136\uff0cGitStatX \u6700\u7ec8\u4e5f\u6b63\u786e\u63d0\u4ea4\u5230 Mac App Store\uff0c\u5e76\u4e14\u7a0b\u5e8f\u8fdb\u5165\u4e86 Waiting For Review \u72b6\u6001\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\"><\/span>\u53c2\u8003\u8d44\u6599<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/11821632\/mac-os-app-sandbox-with-command-line-tool\">Mac OS app, sandbox with command line tool?<\/a><\/li>\n<li><a href=\"http:\/\/oleb.net\/blog\/2012\/02\/checking-code-signing-and-sandboxing-status-in-code\/\">Checking Code Signing and Sandboxing Status in Code<\/a><\/li>\n<li><a href=\"http:\/\/developer.apple.com\/library\/ios\/#documentation\/Miscellaneous\/Reference\/EntitlementKeyReference\/Chapters\/EnablingAppSandbox.html\">Entitlement Key Reference<\/a><\/li>\n<\/ol>\n<p>--- EOF ---<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u5f00\u6e90\u4e86 \u4e00\u4e2a gitstats \u7684 GUI \u5e94\u7528 GitStatX\uff0c\u5728\u63d0\u4ea4\u5230 &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/xujiwei.com\/blog\/2013\/02\/embed-third-party-binary-in-sandboxed-mac-app\/\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,168],"tags":[237,236,147,95],"_links":{"self":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/592"}],"collection":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":0,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"wp:attachment":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}