@[TOC](Qt 在mac上生成pkg安装包)## 标题

1、使用Qt Creator编译出Release版本

2、将生成的app程序拷贝到新的目录

3、使用macdeployqt添加依赖库

macdeployqt是qt软件自带的工具,可在安装路径中找到,
比如我的就在:~/Qt5.14.1/5.14.1/clang_64/bin/macdeployqt右键点击生成的app,选择 Show Package Contents

进入终端输入命令

 ~/Qt5.14.1/5.14.1/clang_64/bin/macdeployqt hippo16.app

如果该app是使用命令cp过去的,可能会在使用macdeployqt时报错,可能是权限的问题,此处我没有深究,直接用鼠标重新复制粘贴一次即可解决问题。


虽然macdeployqt帮助我们添加了大部分的依赖库,但可能还缺少了库。此时我们可以使用otool查看缺少的库。

otool -L hippo16.app/Contents/MacOS/hippo16
strack@STRACKdeMBP csdn % otool -L hippo16.app/Contents/MacOS/hippo16
hippo16.app/Contents/MacOS/hippo16:@rpath/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets (compatibility version 5.14.0, current version 5.14.1)@rpath/QtMultimedia.framework/Versions/5/QtMultimedia (compatibility version 5.14.0, current version 5.14.1)@rpath/QtCharts.framework/Versions/5/QtCharts (compatibility version 5.14.0, current version 5.14.1)@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.14.0, current version 5.14.1)@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.14.0, current version 5.14.1)/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1894.40.150)/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 212.5.15)@rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.14.0, current version 5.14.1)@rpath/QtXml.framework/Versions/5/QtXml (compatibility version 5.14.0, current version 5.14.1)@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.14.0, current version 5.14.1)/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

从上面可以看到,有些库还是从系统里查找的

/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

此时我们可以在Frameworks下新建一个文件夹 utiLib,根据上面的提示,将所需要的系统的库添加到utiLib中。


此时我们就已经将所需要的库都打包好了,只是想要程序在其他电脑上运行,还需修改app运行时查找库的路径。

#!/bin/sh
install_name_tool -change "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit" "@rpath/utilLib/AppKit" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/System/Library/Frameworks/Metal.framework/Versions/A/Metal" "@rpath/utilLib/Metal" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration" "@rpath/utilLib/DiskArbitration" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit" "@rpath/utilLib/IOKit" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL" "@rpath/utilLib/OpenGL" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/System/Library/Frameworks/AGL.framework/Versions/A/AGL" "@rpath/utilLib/AGL" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/usr/lib/libc++.1.dylib" "@rpath/utilLib/libc++.1.dylib" hippo16.app/Contents/MacOS/hippo16;
install_name_tool -change "/usr/lib/libSystem.B.dylib" "@rpath/utilLib/libSystem.B.dylib" hippo16.app/Contents/MacOS/hippo16;

此时app已经能运行了。

4、申请许可证书

首先在电脑本地申请一个证书

密钥位置:/Applications/Utilities/Keychain Access


进入苹果开发者官网申请证书

https://developer.apple.com/account/#!/overview/76SLQT6KY4



选择签名在本地申请的文件,点击continue即可盛出许可,将其下载下来,再双击打开加入到密钥即可。

5、签名

给库签名

1、将Frameworks下每个文件夹(utilLib除外)下 xxx.app/Contents/Frameworks/xxx/version/5(QT版本,看自己实际情况)/Qtxxx 签名

例如:

codesign --entitlements ~/Qt5.14.1/user_app/mixer_ui/main_ui/hippo16/hippo16.entitlements  -s "3rd Party Mac Developer Application: 公司名(xxxxxxx)" hippo16.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus

2、给utilLib下所有文件签名
例如:

codesign --entitlements ~/Qt5.14.1/user_app/mixer_ui/main_ui/hippo16/hippo16.entitlements  -s "3rd Party Mac Developer Application: 公司名(xxxxxxx)" hippo16.app/Contents/Frameworks/utilLib/OpenGL

3、给 Plugins文件夹下所有库签名
例如:

codesign --entitlements ~/Qt5.14.1/user_app/mixer_ui/main_ui/hippo16/hippo16.entitlements  -s "3rd Party Mac Developer Application: 公司名(xxxxxxx)"  hippo16.app/Contents/Plugins/mediaservice/libqtmedia_audioengine.dylib

签名可用命令 codesign -dvvv xxx.app 查看情况

给app签名

先用xcode生成一个entitlements文件,生成一个xcode项目文件:qmake xxx.pro -spec macx-xcode

在xcode中编译一次,将生成的entitlements文件拷到当前文件夹即可

codesign --entitlements ~/Qt5.14.1/user_app/mixer_ui/main_ui/hippo16/hippo16.entitlements  -s "3rd Party Mac Developer Application: 公司名(xxxxxxx)" hippo16.app

打包成pkg

productbuild --component hippo16.app /Applications  --sign '3rd Party Mac Developer Installer: 公司名(xxxxxxx)' hippo16.pkg

至此,安装包就制作完成了,可以双击运行安装,也可通过命令行安装,在此我建议使用命令行安装,能看到安装的一些信息,命令如下:

sudo installer -store -pkg Joop.pkg -target /

Qt 在mac上使用证书签名并生成pkg安装包相关推荐

  1. 越狱设备免证书生成ipa安装包

    本文根据http://bbs.weiphone.com/read-htm-tid-7056725.html修改而来. 前提:     众所周知,在Xcode上开发的程序只能在模拟器中运行,如果要放到真 ...

  2. 【QT】QT生成.exe安装包详细全文(保姆级教程)--打包软件及问题大全

    缺少.dll文件的朋友,请跳转到我的另一篇文章"QT编译后的.exe文件运行时缺少一些.dll文件的解决办法[超详细教程,新手必备]",把问题解决再往下看. 一.前言: 最近,一个 ...

  3. Qt for Android / ios 将图片或文件打包进安装包中

    概述 用 Qt 做程序开发,图片或翻译文件的引用有两种方式,一种是直接引用,本地图片, 一种是编译到资源文件中,其实直接添加在资源文件中是最方便的,不需要考虑文件存放的问题,但是这样可能带来的问题是启 ...

  4. 获取手机上已安装应用,游戏的安装包

    有些时候我们手机上安装好用的app,但后来找不到下载链接了,又想分享给好朋友,就可以用此应用将手机上安装的app安装包文件(.apk)保存到手机本地,然后用其他文件分享工具将安装包分享给好友安装,使用 ...

  5. 怎么在电脑上找到自己安装的软件的安装包

    以Visual Studio Code为例,先找到桌面的快捷方式的图标,然后单击鼠标右键,选择[属性] 选择[快捷方式]中[打开文件所在的位置] 找到文件所在位置的上一级 该文件夹即是我们要找的安装包

  6. Qt在mac上的字体

    系列 fontName 字样 styleName shotcut 报隶-简 "Baoli SC" 常规体 "Regular" 冬青黑体简体中文 "Hi ...

  7. mac上如何测试html,Mac上实现Python用HTMLTestRunner生成html测试报告

    一.导入HTMLTestRunner文件 首先,我们要知道如果要利用HTMLTestRunner生成测试报告的话,就需要对其进行导入: 下载好了之后需要把这个文件复制到python的lib目录下面,操 ...

  8. mac 卸载pkg安装包

    最近想安装一个pkg包的NetworkConnect的VPN,可是忘了什么时候安装的了,在应用管理也总是找不到,提示如下: 我就郁闷了,已经删除了为啥还提示啊. 解决方案 Mac有内置的pkgutil ...

  9. 解决Mac Big Sur系统无权限Install Adobe安装包

    一.没有权限打开应用程序Install (下载完到安装了,结果"没有权限"??) 二.查看安装包(.dmg)的权限 (找到安装包的位置,复制!) 在终端里输入ls -l ,后面粘贴 ...

最新文章

  1. 基于CSDN完成TEASOFT的MOOC编辑整理
  2. java 两个日期的天数_java计算两个日期之间的天数
  3. 集成学习(ensemble learning)(二)
  4. MySQL数据库优化技巧(二)
  5. C#学习笔记五面向对象基础
  6. LeetCode 1664. 生成平衡数组的方案数(前缀和+后缀和)
  7. 新的一年到来了,我要做的第一件事是放弃……
  8. golang中defer语句使用小结
  9. 《TCP/IP详解》读书笔记
  10. devc运行不出窗口_足不出户“云出庭”?沾化“智慧检务”让法律监督“不打烊...
  11. ubtil类oracle,oracle中报错Connect internal only, until freed
  12. linux rzsz 安装包,安装rzsz软件包全攻略
  13. 计算机联锁系统冗余试验,计算机联锁系统冗余技术及应用研究
  14. crmeb多商户二开crmeb类库二开文档services服务类【5】
  15. 面试你对计算机未来三年内规划,2019农商银行面试:谈谈你未来3年的规划
  16. 第一篇 微信开发 准备工作(转载自walkingmanc的专栏)【转】
  17. 电信增值业务学习笔记(转)
  18. manjaro 折腾总结
  19. XML介绍与使用及简单注解
  20. Chrome谷歌浏览器的WeChat微信模拟器,既可以设置模拟很多型号的手机设备Mozilla

热门文章

  1. 51单片机学习——PWM
  2. 中段尾段全段什么意思_什么头什么尾?汽车改装排气时有的换全段,中尾段,尾段,分别都有什么效果?...
  3. 计算机硬件耗电,耗电大户不一定就“费电”_主板评测-中关村在线
  4. FYD-Focus Your Distribution-关注你的分布:异常检测和定位的从粗到细的非对比性学习-FYD
  5. 世界上最神奇的数字是: 142857
  6. 电池行业如何去除碳酸锂溶液中的钙镁离子
  7. 计算机网络工程主要是做什么,网络工程专业是什么
  8. iOS 边学边记 直播SRT、UDT协议详解
  9. 2008 r2 server sql 中文版补丁_Microsoft SQL Server 2008 R2 SP1补丁 32位 官方免费版(附安装教程)...
  10. [mac]强制退出Mac程序的六种方法