在 Sandboxed Mac App 中嵌入第三方可执行文件
来源:互联网 发布:淘宝上美的官方旗舰店 编辑:程序博客网 时间:2024/05/29 03:19
之前开源了 一个 gitstats 的 GUI 应用 GitStatX,在提交到 GitHub (GitStatX) 之后,又准备提交到 Mac App Store。
在提交到 Mac App Store 之后,出现了一些问题,程序中包含的第三方可执行文件没有签名,导致苹果拒绝了提交的程序包:
App sandbox not enabled – 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.
- GitStatX.app/Contents/Resources/git/bin/git
- GitStatX.app/Contents/Resources/gnuplot/gnuplot
但是 GitStatX 所包含的 git 以及 gnuplot,并不是我程序中的代码,也没有 Xcode 工程去使用一个 entitlements 文件来指定它为启用 sandbox 状态。
所幸在网上搜索的时候,找到了可以使用 codesign
工具来进行签名的方法。
检查可执行文件是否启用 sandbox
codesign --display --entitlements - ./commandlinetool
给可执行文件签名并启用 sandbox
先在命令行工具同目录创建一个 entitlements.plist:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.inherit</key> <true/></dict></plist>
这里设置了 com.apple.security.app-sandbox 为 true 来启用 sandbox。
然后使用 codesign 进行签名:
codesign -s "3rd Party Mac Developer Application: Your Name" --entitlements ./entitlements.plist ./commandlinetool
记得把 “3rd Party Mac Developer Application: Your Name” 替换为实际的证书名称。
问题
在给 gnuplot 签名之后,提交到 Mac App Store,苹果还是会自动验证并发邮件说 gnuplot 没有签名,于是在本地直接导出 GitStatX.app,并检查了一下,发现 gnuplot 的 entitlements 又没有了,但是 git 的 entitlements 还是保留的。在 gnuplot 同目录下,有一个 _CodeSignature 目录,可能是在打包的时候会自动处理。
为了避免这个问题,我就把 gnuplot 也放到了一个 bin 目录下,然后再打包并检查,发现 gnuplot 已经是正确签名并且保留有 entitlements 的了。
当然,GitStatX 最终也正确提交到 Mac App Store,并且程序进入了 Waiting For Review 状态。
参考资料
- Mac OS app, sandbox with command line tool?
- Checking Code Signing and Sandboxing Status in Code
- Entitlement Key Reference
- 在 Sandboxed Mac App 中嵌入第三方可执行文件
- 教你在APP中嵌入翻译功能,不借助第三方软件
- 教你在APP中嵌入翻译功能,不借助第三方软件
- [译]在go可执行文件中嵌入数据
- 怎么在第三方应用中打开自己的APP
- 利用Android Studio在App中集成第三方支付
- How to Codesign Growl.framework for Sandboxed Mac App
- 在第三方浏览器中打开本地app某个activity 使得app多次启动的解决办法
- Android 仿照第三方app 将自己APP显示在打开列表中
- SWT程序中嵌入第三方程序的窗口
- SWT程序中嵌入第三方程序的窗口
- iOS中app第三方托管工具
- ios中代码打开第三方app
- android APP中启动第三方地图
- Qt 嵌入第三方程序
- 调用第三方APP
- Qt 在mac 下添加第三方 framework的方法
- 在Eclipseme中使用第三方库
- excel关闭按钮不能退出
- 数据结构的排序算法(直接插入)
- MongoDB在windows下的安装配置
- 面试题之interleave字符串分析
- Android源码编译整理总结
- 在 Sandboxed Mac App 中嵌入第三方可执行文件
- 类模板(3种)
- LK60xWin.dll LK-607 读卡器
- java读取txt文档到string中
- 基于Ant+Selenium+TestNG的测试框架配置
- Weblogic下的应用程序,客户端打印时提示权限不够
- Linux安装程序Anaconda分析
- 互联网公司笔试面试准备以及注意事项
- java基础--映射表Map