当前位置:   article > 正文

QT for macOS应用程序打包发布App Store记录_qt如何在mac上打包exe应用程序

qt如何在mac上打包exe应用程序

第一次用QT开发mac程序,中间踩过各种坑,在此记录下:

一. 打包

     1. 如果只用了qt的库,直接用macdeployqt打包就可以了,会按照苹果要求的目录结构把库都拷进去;

   2. 如果程序中用到了第三方的库,则先执行步骤1,再把用到的库拷进.app/Contents/Frameworks/目录下;

这里注意一点:需要修改库的包含路径 用otool -L( 例:otool -L myApp.app/Contents/MacOS/myApp )命令来查看程序依赖库,把第三方库的加载路径改成跟QT自带的库一样,.app/Contents/Frameworks/目录为:@rpath/;这里还有一个问题,就是第三方库可能还有些依赖库,跟上面方法一样,拷进来然后修改依赖关系;修改指令如下:

install_name_tool -change "/usr/local/lib/libusb-0.1.4.dylib"(原依赖路径) "@executable_path/libusb-0.1.4.dylib"(新的依赖路径) ./bin/Release/libGinkgo_Driver.dylib(修改的文件);

注:修改一次保存起来,以后再打新包直接拷贝就可以了;

二.  签名

      签名相对比较复杂些:

      1. 准备好苹果的发布证书(需要开发证书和安装证书),把证书下载安装在电脑上;

     对库签名:

    指令:codesign --entitlements ${entitlementPath} -s "${cert}" ${frameworkpath}*

   注:${entitlementPath}:entitlements文件的路径,表示该应用使用电脑的一些权限(iCloud、push     notification、App沙盒等),可以用xcode创建一个新的项目,直接拷贝过来使用;

   ${cert}: 证书名称,这里用的是Developer Application 如:3rd Party Mac Developer Application:     ... Limited (JTS5ZE6933)

    ${frameworkpath}: 库存放的目录:.app/Contents/Frameworks/

    对App签名:

 

     codesign --deep --entitlements ${entitlementPath} -s "${cert}" ${apppath}

    注:${apppath}: .app的路径 其它同上

 

    打成pkg安装包:

   productbuild --component ${apppath} /Applications --sign "${certInstall}" myApplication.pkg

    ${certInstall}: Developer Installer证书,这里跟上面不一样:

    3rd Party Mac Developer Installer: ... Limited (JTS5ZE6933)

 

  2. 打包过程中有个很重要的问题就是修改info.plist

 

    

    这里是我打包用到的各个字段;

    三. 上传App Store

    使用Application Loader工具上传打包好的.pkg文件,这里我碰到过两个问题:

    1. 一直提示info.plist为macOS程序,但是包为ipa文件:我这边是Application Loader的问题,下载了3.1版本的这个问题就没有了;

    2. 程序中用到了QtWebEngine,在QtWebEngineCore.framework中包含了QtWebEngineProcess.app的应用,这里一直提示:

需要修改QtWebEngineProcess.app里面info.plist的CFBundleIdentifier值,把'org.qt-project.Qt.QtWebEngineProcess' 改成'org.qt-project.Qt.myApp.QtWebEngineProcess' ;

 

附:

打包脚本:

#!/bin/sh

/Users/my/Qt5.9.3/5.9.3/clang_64/bin/macdeployqt /Users/my/Documents/chenmq/work/build-myApplication-Desktop_Qt_5_9_3_clang_64bit-Release/myApplication.app

install_name_tool -change libqiniu.so @rpath/libqiniu.so /Users/my/Documents/chenmq/work/build-myApplication-Desktop_Qt_5_9_3_clang_64bit-Release/myApplication.app/Contents/MacOS/myApplication

cp /Users/my/Documents/chenmq/QtTest/build-myApplication-Desktop_Qt_5_9_3_clang_64bit-Release/myApp.app/Contents/Frameworks/* /Users/my/Documents/chenmq/work/build-myApplication-Desktop_Qt_5_9_3_clang_64bit-Release/myApplication.app/Contents/Frameworks/

 

签名脚本:

 

apppath="/Users/my/Documents/chenmq/work/build-myApplication-Desktop_Qt_5_9_3_clang_64bit-Release/myApplication.app"

frameworkpath="${apppath}/Contents/Frameworks/"

pluginpath="${apppath}/Contents/PlugIns/"

cert="3rd Party Mac Developer Application: mingquan(Hong Kong) Limited (JTS5ZE6933)"

certInstall="3rd Party Mac Developer Installer: mingquan(Hong Kong) Limited (JTS5ZE6933)"

entitlementPath="/Users/my/Desktop/mymac/mymac/mymac.entitlements"

 

codesign --entitlements ${entitlementPath} -s "${cert}" ${frameworkpath}*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}accessible/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}audio/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}imageformats/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}mediaservice/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}platforms/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}printsupport/*

codesign --entitlements ${entitlementPath} -s "${cert}" ${pluginpath}sqldrivers/*

codesign --deep --entitlements ${entitlementPath} -s "${cert}" ${apppath}

productbuild --component ${apppath} /Applications --sign "${certInstall}" myApplication.pkg

 

磁盘工具打包:

     qt自带的打包工具macdeployqt会有一个问题,有时候低版本的mac系统会由于文件系统的原因解压不了,具体现象就是解压的文件已损坏的问题,这时候就需要使用磁盘工具生成安装包具体参考:https://blog.csdn.net/weixin_33897722/article/details/86906801

 

参考文档:

 

 

打包:https://blog.csdn.net/imxiangzi/article/details/50994466

https://blog.csdn.net/casun_li/article/details/71741968

签名:https://www.apps121.com/2017/12/22/qtmacappstore/

https://stackoverflow.com/questions/32379982/api-calls-dont-run-when-i-codesign-my-mac-os-x-app

 

 

    

 

 

 


 

 

 

 

 

 

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/291950
推荐阅读
相关标签
  

闽ICP备14008679号